Hello All,
I am defining a ClientScript with ASP, I want to access the variable defined inside the script with a JavaScript script defined on the client side, here is my code:
What am i doing wrong?HTML Code:<script runat="server"> protected void Page_Load(object sender, EventArgs e) { string myScript = @"var _variable = 5;"; Page.ClientScript.RegisterStartupScript(this.GetType(), "MyScript", myScript, true); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Untitled Page</title> <script type="text/javascript"> alert(_variable); </script> </head> <body> <form id="form1" runat="server"> </form> </body> </html>
Thanks in advance.


Reply With Quote

Bookmarks