Render to new page

  • Thread starter Thread starter David C
  • Start date Start date
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
 
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 butit
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
 
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
 
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?
 
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?
 
Back
Top