javascript - Injecting JS into Literal and firing after page load -


i have aspx/c# page on clicking save post server. if content within controls exists in data stores checked supposed pop-up alert. previous programmer used:

<asp:literal id="literror" runat="server" /> 

with code behind sending:

literror.text = "<script type='javascript'>alert('an error occured while processing request.  if error persists, please contact desk.');</script>"; 

this js alert not popping in spite of debug reporting correctly processing through. have scoured internet, including here, several days trying find resolution. have tried many variations fire.

i'm suspecting script cannot fire on ajax because not there during load stage of life cycle, verification.

the script in btnsave_onclick method. unfortunately, due nature of web application cannot show more of code, script should fire on exception of item existing in either app db or if user exists in our ad system already.

i able resolve issue removing use of asp literal control. believe first attempts @ using didn't have formatted string, correctly functioning below code implemented in code behind:

stringbuilder sberror = new stringbuilder();         sberror.append("<script language='javascript' type='text/javascript'>alert('" + strerror + "');</script>");          scriptmanager.registerstartupscript(this, this.gettype(), "sberror", sberror.tostring(), false); 

thanks zaigham , james trying help. believe reason literal control method did not work because there scriptmanager control on page(s) attempting use method.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -