rss feed Rss FeedAsp.net Coder
learn asp.net & visual studio 2008,this blog share our study record.there are a lot of solution and source code of building web application using asp.net

Page.ClientScript.RegisterStartupScript does not fire on button click event

Author:Linlin  PostAt:Wed, 26 Nov 2008 10:58:21 GMT Posted In:Asp.net Starter
Q:

in one ascx control there is a button, and i write onclick event of that

now in onclick event i written

        Page.ClientScript.RegisterStartupScript(this.GetType(), "Error", "<script type=\"text/javascript\">alert('hi');</script>");


but it doesnot fire alert message

what's the problem

thanks 

A:

 try this:

Page.ClientScript.RegisterStartupScript(this.GetType(), "Error","alert('hi');", true);

there isa no need of <script> tag if you use  Page.ClientScript.RegisterStartupScript

A:

the correct synatx is :

Page.ClientScript.RegisterStartupScript(this.GetType(), "Error","alert('hi');", true);

no need of <script> tag

A:


Try this way instead.

System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Test", "javascript:alert('Hi there!');", true); 

Previous: adding pixel spacing in html
hi,Is there anyway of adding a pixel space in html as it is done by the &nbsp with spaces? I′m strying to place a label in an exact position but I′m a couple of pixels short.THX in advanced, Malcolm ... more
Next: None