Subject: RE: how to call aspx variable from Javascript
Date: Tue, 11 Nov 2003 10:12:37 -0800
Lines: 72
Message-ID: <
[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Thread-Index: AcOof2MGsd833c3lTq29mA5i2VBUfg==
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Newsgroups: microsoft.public.dotnet.framework.aspnet
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:190128
NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
the thing is I need to do it on the client side. I've
tried <% = jsTestServer %> before. It didn't work. It
didn't even pop up the alert this time. Or maybe I did
something wrong. Could you please give me a more
complete piece of code?
Thanks!
-----Original Message-----
Jade,
Assuming that variable is in scope, you would use the following:
<% = jsTestServer %>
Actually, what you should do is use
RegisterClientScriptBlock to generate
your client-side script on the server and then register it on the client.
Jim Cheshire [MSFT]
Developer Support
ASP.NET
(e-mail address removed)
This post is provided as-is with no warranties and confers no rights.
--------------------
Content-Class: urn:content-classes:message
From: "Jade" <
[email protected]>
Sender: "Jade" <
[email protected]>
Subject: how to call aspx variable from Javascript
Date: Tue, 11 Nov 2003 09:30:27 -0800
Lines: 16
Message-ID: <
[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcOoeX8iZVlOZ5x5TzC4ue9n01Hi8w==
Newsgroups: microsoft.public.dotnet.framework.aspnet
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:190114
NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
I saw some web page saying I could do it this way in
javascript:
var iNumber = <%#publicvarname [or] publicpropertyname %
but it doesn't seem to work. I have this piece of code
here in javascript:
<script language="javascript">
var sessionServer = "<%#jsTestServer%>";
alert(sessionServer);
</script>
and the variable is defined in the C# code behind:
public string jsTestServer
= "\\\\TestServer\\TestSession\\";
when I run it, alert has no message in it.
.