Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run ClientScript in User Control?

I am using the code:

   ClientScript.RegisterStartupScript(typeof(Page), "message", message);

This code works fine in an ASP.NET page but does not in a UserControl. I need to use this functionality in UserControl.

like image 954
None Avatar asked Dec 03 '22 04:12

None


1 Answers

You could try:

    string script = "<script language='JavaScript'>alert('hello');</script>";
    Page.RegisterStartupScript("myscript", script);

or

        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", "<script>alert('Hello.')</script>", false);
like image 117
Ryan Fiorini Avatar answered Dec 16 '22 04:12

Ryan Fiorini