Constant

  • Thread starter Thread starter Don
  • Start date Start date
D

Don

Hi,

does anyone know how to write a constant or variable into
the JScript of the page that can be used by all my JScript
functions? This should be done in the asp.net code!

Thanks for helping me,
Regards
Don
 
Hi...

int i = 10;
Page.RegisterClientScriptBlock("_myv",string.Format("<script>var myVar =
{0};</script>",i));
 
A global variable in JavaScript is a variable that is declared outside of
any function block. Example:

Dim s As String = "<script type=""text/javascript"">var x = 0;</script>"
If Not Page.IsStartupScriptRegistered("MyScript") Then
Page.RegisterStartupScript("MyScript", s)
End If

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
Back
Top