Render to new page

Discussion in 'ASP .Net' started by David C, Jun 4, 2009.

  1. David C

    David C 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
     
    David C, Jun 4, 2009
    #1
    1. Advertising

  2. On Jun 4, 6:09 pm, "David C" <> wrote:
    > 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
     
    Alexey Smirnov, Jun 4, 2009
    #2
    1. Advertising

  3. David C

    David C 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.

    David

    "Alexey Smirnov" <> wrote in message
    news:...
    On Jun 4, 6:09 pm, "David C" <> wrote:
    > 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
     
    David C, Jun 4, 2009
    #3
  4. On Jun 4, 11:23 pm, "David C" <> wrote:
    > 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?
     
    Alexey Smirnov, Jun 4, 2009
    #4
  5. David C

    David C Guest

    I will probably have several.

    David
    "Alexey Smirnov" <> wrote in message
    news:...
    On Jun 4, 11:23 pm, "David C" <> wrote:
    > 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?
     
    David C, Jun 8, 2009
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lau Lei Cheong

    Page.Render do not render complete page

    Lau Lei Cheong, May 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,105
    Lau Lei Cheong
    May 15, 2004
  2. SteveM
    Replies:
    7
    Views:
    476
    John Timney \(MVP\)
    Dec 14, 2006
  3. Glenn Gillen
    Replies:
    0
    Views:
    310
    Glenn Gillen
    Nov 17, 2006
  4. Replies:
    2
    Views:
    501
    Thomas 'PointedEars' Lahn
    Mar 11, 2008
Loading...

Share This Page