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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top