c# - I need to communicate between 2 pages without refreshing the page, with ajax, when a event is raised on the serverside -


to clearify, i've tried solutions updatepanel/scriptmanager not want use them. want make jquery-ajax posts , nothing else.

lets assume scenario.

we have global event follows:

public static class customglobalevents  {      public delegate void specialeventraisedeventhandler(object sender, string type, string msg);      public static event specialeventraisedeventhandler specialeventraised;      public static void specialevent(object sender, string type, string msg)     {         if (specialeventraised != null)             specialeventraised(sender, type, msg);     }  } 

we have 2 web-pages, reciever.aspx , sender.aspx.

reciever.aspx has following code:

protected void page_load(object sender, eventargs e)  {      if(!ispostback)     {         customglobalevents.specialeventraised += new customglobalevents.specialeventraisedeventhandler(customglobalevents_specialeventraised);     }  }  void customglobalevents_specialeventraised(object sender, string type, string msg) {     // } 

sender.aspx has following code:

protected void page_load(object sender, eventargs e) {      if(!ispostback)      {          customglobalevents.specialevent(this.page, "type", "msg");     } } 

what i'd in reciever.aspx event handler special event customglobalevents_specialeventraised want fire javascript on reciever.aspx page.

like doing jquery ajax post , updating information on page.

i have tried injecting javascript scriptmanager since scriptmanager not in async state (even if force update updatepanel.update();) script not page.

another idea try initiate generichandler directly, resulted in sender.aspx getting response instead of reciever following code:

mygenerichandler mygenerichandler = new mygenerichandler(); mygenerichandler.processrequest(httpcontext.current); 

which might make sense since sender.aspx fired event in first place.

with this, nothing happens @ all:

mygenerichandler mygenerichandler = new mygenerichandler(); mygenerichandler.processrequest(this.context); 

the best method obiously fire generichandler , in way make reciever.aspx page recieve response. next best thing tell reciever.aspx fire javascript method.

i've tried create httpmodule try hook up, failed.

best other solution i've seen far jquery ajax post every x seconds. defenatly not want. want fire when needs fired (when server-side event fires).

solutions working iis6 or iis7, fine, asp.net 3.5 , not mvc.

any ideas?

edit: apparently doesn't stackoverflow's -tag public delegates... :)

i don't think thats possible. response exist there must request. server cannot push client. client code has check server status.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -