c# - Using Page.ClientScript.RegisterClientScriptBlock not working -


i trying fire pop shown below, not working. please help

public void btnsubmit_click(object o, eventargs e) {     if (checkfileexists(convert.tostring(fileinfo)))     {         page.clientscript.registerclientscriptblock(this.gettype(), "msg", "<script type=\"text/javascript\"  language=\"javascript\">function showmsg(){return confirm(\"this image name exists, want replace it?\");}</script>", true);         btnsubmit.onclientclick = "return showmsg()";     }     if (something else)     {         // whatever here never pops question above     } } 

and on button have

 <asp:button class="button" id="btnsubmit" causesvalidation="true" text="submit" runat="server"              onclick="btnsubmit_click"></asp:button> 

the last parameter you're sending registerclientscriptblock true, tells method wrap script in <script> block, you're doing that. it's not working, because it's rendering invalid (i.e. nested) script tags.


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 -