Constant

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
 
E

Eugene Jenihov

Hi...

int i = 10;
Page.RegisterClientScriptBlock("_myv",string.Format("<script>var myVar =
{0};</script>",i));
 
K

Kevin Spencer

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

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top