How to access page controls from HttpHandler?

Last post 08-06-2008 3:17 PM by samw. 3 replies.

Sort Posts:

  • How to access page controls from HttpHandler?

    08-06-2008, 12:50 PM
    • Member
      157 point Member
    • samw
    • Member since 06-08-2005, 1:00 PM
    • Posts 145

    In my page, Page.aspx, I have Response.Redirect("Plug.xyz") and that invokes a HttpHandler. 

    In the HttpHandler, I need to access the controls on Page.aspx.  How do I do that?
     

    Thanks 

  • Re: How to access page controls from HttpHandler?

    08-06-2008, 1:08 PM
    Answer
    • Star
      8,650 point Star
    • DavidKiff
    • Member since 12-07-2006, 11:07 PM
    • Hertfordshire, UK
    • Posts 1,733

    You cant!  Response.Redirect sends a (i think) 303 down to the client, the browser then goes to the new url (your new handler.. with no access to the page it came from).  If you use Server.Transfer, then it does not do the round trip, and does the shift server side!  If your HTTP Handler is a page you can do:

    PreviousPage.FindControl("... etc.

  • Re: How to access page controls from HttpHandler?

    08-06-2008, 1:55 PM
    Answer
    • Participant
      1,562 point Participant
    • Peter Bucher
    • Member since 07-16-2007, 2:23 PM
    • Switzerland
    • Posts 214
    • TrustedFriends-MVPs

    Hi samw

    I agree to David.
    It works if you use Server.Transfer() and HttpContext.Current.Items.

  • Re: How to access page controls from HttpHandler?

    08-06-2008, 3:17 PM
    • Member
      157 point Member
    • samw
    • Member since 06-08-2005, 1:00 PM
    • Posts 145

    Thank you both... Server.Transfer() may work for me, however I will also need to set the source of an iframe to Page.xyz.

    What I am trying to do is 1.) upload two files, 2,) run an update query.  I need to display status info during process.  I dont need to give byte-by-byte status during the file uploads, but during the update I need to display progress because it is very long.  Is using a httphandler the best way to do this?

    Thanks 

     

Page 1 of 1 (4 items)