Render to new page

D

David C

I have an asp.net 3.5 web page that displays 2 separate DetailsView
controls. I have the code below in the page-behind that works fine but it
overwrites the current page. Is there an easy way to have this open and
write to a new page or possibly add a button to the rendered page that will
go back to the previous page? Thanks. -David

Sub HtmlPrint()
Dim tw As New StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)

Dim dvtop As DetailsView = dvPropertyInfo
Response.Clear()
Response.ContentType = "text/html"
'Response.AddHeader("content-disposition",
"attachment;filename=search.xls")
Response.Charset = "ISO-8859-13"
EnableViewState = False
dvtop.AllowPaging = False
dvtop.RowStyle.BackColor = Drawing.Color.White
dvtop.AlternatingRowStyle.BackColor = Drawing.Color.White
dvtop.DataBind()
dvtop.RenderControl(hw)
Response.Write(tw.ToString())
Response.Clear()
Response.Write("<hr /><br /><br />")
Response.Clear()

Dim dv As DetailsView = dvPropertyAndBusiness
dv.RowStyle.BackColor = Drawing.Color.White
dv.AlternatingRowStyle.BackColor = Drawing.Color.White
dv.AllowPaging = False
dv.DataBind()

dv.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
End Sub

Public Overrides Sub VerifyRenderingInServerForm(ByVal control As
System.Web.UI.Control)

End Sub

Protected Sub BtnPrint_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles BtnPrint.Click
HtmlPrint()
End Sub
 
G

Guest

I have an asp.net 3.5 web page that displays 2 separate DetailsView
controls.  I have the code below in the page-behind that works fine but it
overwrites the current page.  Is there an easy way to have this open and
write to a new page or possibly add a button to the rendered page that will
go back to the previous page?  Thanks.  -David

    Sub HtmlPrint()
        Dim tw As New StringWriter()
        Dim hw As New System.Web.UI.HtmlTextWriter(tw)

        Dim dvtop As DetailsView = dvPropertyInfo
        Response.Clear()
        Response.ContentType = "text/html"
        'Response.AddHeader("content-disposition",
"attachment;filename=search.xls")
        Response.Charset = "ISO-8859-13"
        EnableViewState = False
        dvtop.AllowPaging = False
        dvtop.RowStyle.BackColor = Drawing.Color.White
        dvtop.AlternatingRowStyle.BackColor = Drawing.Color.White
        dvtop.DataBind()
        dvtop.RenderControl(hw)
        Response.Write(tw.ToString())
        Response.Clear()
        Response.Write("<hr /><br /><br />")
        Response.Clear()

        Dim dv As DetailsView = dvPropertyAndBusiness
        dv.RowStyle.BackColor = Drawing.Color.White
        dv.AlternatingRowStyle.BackColor = Drawing.Color.White
        dv.AllowPaging = False
        dv.DataBind()

        dv.RenderControl(hw)
        Response.Write(tw.ToString())
        Response.End()
    End Sub

    Public Overrides Sub VerifyRenderingInServerForm(ByVal control As
System.Web.UI.Control)

    End Sub

    Protected Sub BtnPrint_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles BtnPrint.Click
        HtmlPrint()
    End Sub

My first question is, what do you do by writing the following lines:
Response.Clear()
Response.Write("<hr /><br /><br />")
Response.Clear()

you remove the output from above, it means that dvtop.DataBind(), etc
are generated but not visible...

This "print" view is generated by clicking on BtbPrint button. So, one
of the options could be a link on the "print" view to go back:

Response.Write("<a href=/>Go Back</a>")
Response.End()
End Sub

and then user clicks on it he/she will be redirected back to the
original page (you need to set url there, or use javascript:goback
(-1))

Another option is to make Print.aspx and put all your "print" code
there
 
D

David C

I like the Print.aspx option. How could I retrieve the 2 DetailsView from
the previous page? I would like to be able to use one "print" page no
matter whether the previous page contains a Detailsview, GridView or ???
Thanks.

David

I have an asp.net 3.5 web page that displays 2 separate DetailsView
controls. I have the code below in the page-behind that works fine but it
overwrites the current page. Is there an easy way to have this open and
write to a new page or possibly add a button to the rendered page that
will
go back to the previous page? Thanks. -David

Sub HtmlPrint()
Dim tw As New StringWriter()
Dim hw As New System.Web.UI.HtmlTextWriter(tw)

Dim dvtop As DetailsView = dvPropertyInfo
Response.Clear()
Response.ContentType = "text/html"
'Response.AddHeader("content-disposition",
"attachment;filename=search.xls")
Response.Charset = "ISO-8859-13"
EnableViewState = False
dvtop.AllowPaging = False
dvtop.RowStyle.BackColor = Drawing.Color.White
dvtop.AlternatingRowStyle.BackColor = Drawing.Color.White
dvtop.DataBind()
dvtop.RenderControl(hw)
Response.Write(tw.ToString())
Response.Clear()
Response.Write("<hr /><br /><br />")
Response.Clear()

Dim dv As DetailsView = dvPropertyAndBusiness
dv.RowStyle.BackColor = Drawing.Color.White
dv.AlternatingRowStyle.BackColor = Drawing.Color.White
dv.AllowPaging = False
dv.DataBind()

dv.RenderControl(hw)
Response.Write(tw.ToString())
Response.End()
End Sub

Public Overrides Sub VerifyRenderingInServerForm(ByVal control As
System.Web.UI.Control)

End Sub

Protected Sub BtnPrint_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles BtnPrint.Click
HtmlPrint()
End Sub

My first question is, what do you do by writing the following lines:
Response.Clear()
Response.Write("<hr /><br /><br />")
Response.Clear()

you remove the output from above, it means that dvtop.DataBind(), etc
are generated but not visible...

This "print" view is generated by clicking on BtbPrint button. So, one
of the options could be a link on the "print" view to go back:

Response.Write("<a href=/>Go Back</a>")
Response.End()
End Sub

and then user clicks on it he/she will be redirected back to the
original page (you need to set url there, or use javascript:goback
(-1))

Another option is to make Print.aspx and put all your "print" code
there
 
G

Guest

I like the Print.aspx option.  How could I retrieve the 2 DetailsView from
the previous page?  I would like to be able to use one "print" page no
matter whether the previous page contains a Detailsview, GridView or ???
Thanks.

How many different pages to print do you have? Just two?
 
D

David C

I will probably have several.

David
I like the Print.aspx option. How could I retrieve the 2 DetailsView from
the previous page? I would like to be able to use one "print" page no
matter whether the previous page contains a Detailsview, GridView or ???
Thanks.

How many different pages to print do you have? Just two?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,154
Members
46,701
Latest member
XavierQ83

Latest Threads

Top