locked
how to access a page control from ihttpHandler? RRS feed

  • Question

  • User-1007320897 posted

    hi,

    i create a class which implemented ihttpHandler, now i want to access a control defined on the page with 'run=server' attribute set.

    is it possible?

    my current solution is to save a reference of that control in session object, but i do not think that's a good idea

    Friday, April 20, 2007 4:08 AM

Answers

  • User-225114762 posted

    isn't Atlas changed is name to Ajax.NET?

    Yes.

     ICallbackEventHandler.RaiseCallbackEvent() post back only one argument, so how can i distinguish by which event this callback is issued?

    You serialize your argument and response in any appropriate way, i.e. you must embed all the information you need in the one string for both request and response.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 24, 2007 1:11 AM

All replies

  • User-225114762 posted
    If your HttpHandler derives directly or indirectly from Control (i.e. Page), you have the Controls property which gives you a ControlCollection. If you're doing it all by yourself, you should have the corresponding property and ControlCollection that you can work with.
    Friday, April 20, 2007 6:41 AM
  • User-1007320897 posted

    hi,

    my class derives from WebControl, and implemented IHttpHandler and IRequireSessionState. i cant access those properties, but my control also have a EventHandler, but it's always empty.

    but if i save the object in the session object, the eventHandler is set. any idea?? 

    Friday, April 20, 2007 10:56 PM
  • User-1007320897 posted

    i think i made a big mistake...

    my ihttpHandler is invoked by a WebRequest from the client-side, so the system will not have any idea about the context of my web control, right?

    my problem is that i have a web control which have a serverside event, and i want to invoke it from a ihttpHandler not a ipostbackEventHandler, is that possible?

    Friday, April 20, 2007 11:13 PM
  • User-225114762 posted
    I'm not quite sure, but it sounds a bit like you've placed markup referring to your WebControl-derived class on an aspx-page? That's not what you want to do, at least not if you want to implement IHttpHandler. Are you familiar with the contents of the following http://msdn.microsoft.com/en-us/library/5c67a8bd(VS.71).aspx ? If not, read all the subsections carefully. Perhaps you don't want to write a HttpHandler at all? Please explain further just what you want to accomplish.
    Saturday, April 21, 2007 5:03 AM
  • User-1007320897 posted

    i haven't learned that yet, thanks for telling!

    i will read and post back latter, thanks 

    Saturday, April 21, 2007 10:33 AM
  • User-1007320897 posted

    well...maybe i've read it before, can't remember clearly

    i want to create a Control which derives from WebControl, when the page is loaded, this control will create a client-side javascript object, which works like a agent of the control at the server-side. when the user click a button that is associated with the javascript object, the object makes a request by using the Sys.Net.WebRequest class, the request will be direct to a HttpHandler in which i want to access the control.

     i think i should use a web service to implement my solution, if then i will re-write almost all my code...

    i hope i explained myself clear, and i hope you could help me, or give a some suggestion, thanks!
     

    Saturday, April 21, 2007 10:46 AM
  • User-225114762 posted

    i want to create a Control which derives from WebControl, when the page is loaded, this control will create a client-side javascript object, which works like a agent of the control at the server-side. when the user click a button that is associated with the javascript object, the object makes a request by using the Sys.Net.WebRequest class, the request will be direct to a HttpHandler in which i want to access the control.

    I'm afraid it's still not entirely clear. Are you saying that the client-side script invokes something on the server, which turn issues a HTTP request to the same server, and you want the HttpHandler responding to that request to access the original control? If so, you need to rethink your architecture. Essentially - you can't do that, and you don't want to either.

    Just what are you trying to achieve? If you explain not so much how you want to implement it, but rather what it is you want to do, we can come up with a suggestion on how to actually make it work?

    Sunday, April 22, 2007 6:40 AM
  • User-1007320897 posted

    hi,

    yes, that's what i want to do!

    i thank i should change my architecture, maybe i should use the ICallBackEventHandler to implement it.

     ICallBackEventHandler also makes a web page feels like a AJAX one, right?

    Monday, April 23, 2007 6:56 AM
  • User-225114762 posted

    If you're trying to do an update without posting the entire page, you should be indeed be using the client callback interface. Checkout http://msdn.microsoft.com/en-us/library/ms178208.aspx . It's the built-in, lightweight "ajax" of ASP.NET 2.0. There's also the Atlas framework, but that might be more than you need.

    In any case, you do not want your code on the server to issue any web requests to itself.

    Monday, April 23, 2007 9:00 AM
  • User-1007320897 posted

    isn't Atlas changed is name to Ajax.NET?

    if not, what's the difference about Atlas framework and AJAX.NET?

     

    and ICallbackEventHandler.RaiseCallbackEvent() post back only one argument, so how can i distinguish by which event this callback is issued? append the event name as part of the argument which is post back?

    Monday, April 23, 2007 10:10 PM
  • User-225114762 posted

    isn't Atlas changed is name to Ajax.NET?

    Yes.

     ICallbackEventHandler.RaiseCallbackEvent() post back only one argument, so how can i distinguish by which event this callback is issued?

    You serialize your argument and response in any appropriate way, i.e. you must embed all the information you need in the one string for both request and response.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, April 24, 2007 1:11 AM
  • User-225114762 posted

    isn't Atlas changed is name to Ajax.NET?
    Yes.

    Or rather, ASP.NET Ajax, to be more precise.

    Tuesday, April 24, 2007 1:13 AM
  • User-1007320897 posted

    hi,

    thanks!

    that's the solution i am trying to use! 

    Tuesday, April 24, 2007 6:15 AM