.net - Javascript not executing from ASP.NET -


please @ code , find out why isnt working. not getting alert in webpage. but, console.writeline beneath getting executed.

    private void publishloop()     {         while (running)         {                       thread.sleep(5000);             dtmessages = (string)(cache.get(key));             if (dtmessages == null)             {                 //publish here                 dtmessages = loadmessages();                 system.diagnostics.debugger.log(0,null,dtmessages);                 page.clientscript.registerstartupscript(this.gettype(),"clientscript", "alert('hi');",true);                 console.writeline(dtmessages);             }         }       } 

edit: can register 1 unique key per response. you're running line of code inside while loop, keeps registering same key. need give unique key parameter each time call function. in case, maybe can have counter in loop , append key string

int = 0; while (running)         {                       thread.sleep(5000);             dtmessages = (string)(cache.get(key));             if (dtmessages == null)             {                 //publish here                 dtmessages = loadmessages();                 system.diagnostics.debugger.log(0,null,dtmessages);                 page.clientscript.registerstartupscript(this.gettype(),"clientscript" + i.tostring(), "alert('hi');",true);                 console.writeline(dtmessages);                 i++;             }         } 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -