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. 8 4810
"Jade" <an*******@discussions.microsoft.com> wrote in
news:12****************************@phx.gbl: 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.
Jade,
Try <%= jsTestServer %> instead of <%# jsTestServer %>.
Hope this helps.
Chris.
-------------
C.R. Timmons Consulting, Inc. http://www.crtimmonsinc.com/
<%# is the DataBinding syntax. You need to make sure you call DataBind() on
your page (in the server code. You can also use <%=someVariable%>, which
will print the value out when it runs. The DataBind way is a little more
elegant, I feel.
-mike
MVP
"Jade" <an*******@discussions.microsoft.com> wrote in message
news:12****************************@phx.gbl... 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.
It still doesn't work. Here is exactly what I have now:
<script language="javascript">
var sessionServer = "<%=jsTestServer%>";
alert(sessionServer);
function CreateSessionFlag()
{
alert("hello");
}
function DeleteSessionFlag()
{
alert("bye");
}
</script>
</head>
<body MS_POSITIONING="GridLayout"
onLoad="CreateSessionFlag();">
In the C# code behind:
public class WebForm1 : System.Web.UI.Page
{
public string jsTestServer
= "\\\\ze483z\\TestSession\\";
private void Page_Load(object sender, System.EventArgs
e)
{ // Put user code to initialize the page here }
It's a very simple test program. After I changed to "<%
=jsTestServer%>", it generates some jscript error -
object expected on the "onload" line. If I used the old
way var sessionServer = "<%#jsTestServer%>"; it pops up
an alert with empty message. -----Original Message----- <%# is the DataBinding syntax. You need to make sure
you call DataBind() onyour page (in the server code. You can also use <%
=someVariable%>, whichwill print the value out when it runs. The DataBind way
is a little moreelegant, I feel.
-mike MVP
"Jade" <an*******@discussions.microsoft.com> wrote in
messagenews:12****************************@phx.gbl... 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.
.
Check out HTML output. If you have \\ characters, they will get interpreted
by C#. Try with your variable as "Hello, JScript!" :).
Using the <%# syntax, did you do a this.DataBind(); call in your OnLoad or
somewhere?
-mike
MVP
<an*******@discussions.microsoft.com> wrote in message
news:14****************************@phx.gbl... It still doesn't work. Here is exactly what I have now:
<script language="javascript"> var sessionServer = "<%=jsTestServer%>"; alert(sessionServer);
function CreateSessionFlag() { alert("hello"); }
function DeleteSessionFlag() { alert("bye"); } </script> </head> <body MS_POSITIONING="GridLayout" onLoad="CreateSessionFlag();">
In the C# code behind: public class WebForm1 : System.Web.UI.Page { public string jsTestServer = "\\\\ze483z\\TestSession\\";
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here }
It's a very simple test program. After I changed to "<% =jsTestServer%>", it generates some jscript error - object expected on the "onload" line. If I used the old way var sessionServer = "<%#jsTestServer%>"; it pops up an alert with empty message.
-----Original Message----- <%# is the DataBinding syntax. You need to make sure you call DataBind() onyour page (in the server code. You can also use <% =someVariable%>, whichwill print the value out when it runs. The DataBind way is a little moreelegant, I feel.
-mike MVP
"Jade" <an*******@discussions.microsoft.com> wrote in messagenews:12****************************@phx.gbl... 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.
.
It did interpreted correctly in HTML:
var sessionServer = "\\ze483z\TestSession\";
where/how should I use "this.DataBind();" exactly in
Onload??? -----Original Message----- Check out HTML output. If you have \\ characters, they
will get interpretedby C#. Try with your variable as "Hello, JScript!" :).
Using the <%# syntax, did you do a this.DataBind(); call
in your OnLoad orsomewhere?
-mike MVP
<an*******@discussions.microsoft.com> wrote in message news:14****************************@phx.gbl... It still doesn't work. Here is exactly what I have
now: <script language="javascript"> var sessionServer = "<%=jsTestServer%>"; alert(sessionServer);
function CreateSessionFlag() { alert("hello"); }
function DeleteSessionFlag() { alert("bye"); } </script> </head> <body MS_POSITIONING="GridLayout" onLoad="CreateSessionFlag();">
In the C# code behind: public class WebForm1 : System.Web.UI.Page { public string jsTestServer = "\\\\ze483z\\TestSession\\";
private void Page_Load(object sender,
System.EventArgs e) { // Put user code to initialize the page here }
It's a very simple test program. After I changed
to "<% =jsTestServer%>", it generates some jscript error - object expected on the "onload" line. If I used the
old way var sessionServer = "<%#jsTestServer%>"; it pops up an alert with empty message.
>-----Original Message----- ><%# is the DataBinding syntax. You need to make sure you call DataBind() on >your page (in the server code. You can also use <% =someVariable%>, which >will print the value out when it runs. The DataBind
way is a little more >elegant, I feel. > >-mike >MVP > >"Jade" <an*******@discussions.microsoft.com> wrote in message >news:12****************************@phx.gbl... >> 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. > > >. >
.
> It did interpreted correctly in HTML: var sessionServer = "\\ze483z\TestSession\";
Right, and that's not valid for JScript, thus the runtime error.
where/how should I use "this.DataBind();" exactly in Onload???
this.DataBind(); // That's it
That binds all the <%# markers.
-mike
MVP -----Original Message----- Check out HTML output. If you have \\ characters, they will get interpretedby C#. Try with your variable as "Hello, JScript!" :).
Using the <%# syntax, did you do a this.DataBind(); call in your OnLoad orsomewhere?
-mike MVP
<an*******@discussions.microsoft.com> wrote in message news:14****************************@phx.gbl... It still doesn't work. Here is exactly what I have now: <script language="javascript"> var sessionServer = "<%=jsTestServer%>"; alert(sessionServer);
function CreateSessionFlag() { alert("hello"); }
function DeleteSessionFlag() { alert("bye"); } </script> </head> <body MS_POSITIONING="GridLayout" onLoad="CreateSessionFlag();">
In the C# code behind: public class WebForm1 : System.Web.UI.Page { public string jsTestServer = "\\\\ze483z\\TestSession\\";
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here }
It's a very simple test program. After I changed to "<% =jsTestServer%>", it generates some jscript error - object expected on the "onload" line. If I used the old way var sessionServer = "<%#jsTestServer%>"; it pops up an alert with empty message.
>-----Original Message----- ><%# is the DataBinding syntax. You need to make sure you call DataBind() on >your page (in the server code. You can also use <% =someVariable%>, which >will print the value out when it runs. The DataBind way is a little more >elegant, I feel. > >-mike >MVP > >"Jade" <an*******@discussions.microsoft.com> wrote in message >news:12****************************@phx.gbl... >> 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. > > >. >
.
I'm sorry, Mike. I still don't know where to
put "this.DataBind();" I put it in
private void Page_Load(object sender, System.EventArgs e)
{
this.DataBind();
}
and I still have the runtime error. -----Original Message----- It did interpreted correctly in HTML: var sessionServer = "\\ze483z\TestSession\"; Right, and that's not valid for JScript, thus the
runtime error. where/how should I use "this.DataBind();" exactly in Onload???
this.DataBind(); // That's it
That binds all the <%# markers.
-mike MVP
>-----Original Message----- >Check out HTML output. If you have \\ characters,
they will get interpreted >by C#. Try with your variable as "Hello,
JScript!" :). > >Using the <%# syntax, did you do a this.DataBind();
call in your OnLoad or >somewhere? > >-mike >MVP > ><an*******@discussions.microsoft.com> wrote in message >news:14****************************@phx.gbl... >> It still doesn't work. Here is exactly what I have now: >> >> <script language="javascript"> >> var sessionServer = "<%=jsTestServer%>"; >> alert(sessionServer); >> >> function CreateSessionFlag() >> { >> alert("hello"); >> } >> >> function DeleteSessionFlag() >> { >> alert("bye"); >> } >> </script> >> </head> >> <body MS_POSITIONING="GridLayout" >> onLoad="CreateSessionFlag();"> >> >> In the C# code behind: >> public class WebForm1 : System.Web.UI.Page >> { >> public string jsTestServer >> = "\\\\ze483z\\TestSession\\"; >> >> private void Page_Load(object sender, System.EventArgs >> e) >> { // Put user code to initialize the page here } >> >> It's a very simple test program. After I changed to "<% >> =jsTestServer%>", it generates some jscript error - >> object expected on the "onload" line. If I used the old >> way var sessionServer = "<%#jsTestServer%>"; it
pops up >> an alert with empty message. >> >> >> >-----Original Message----- >> ><%# is the DataBinding syntax. You need to make
sure >> you call DataBind() on >> >your page (in the server code. You can also use <% >> =someVariable%>, which >> >will print the value out when it runs. The
DataBind way >> is a little more >> >elegant, I feel. >> > >> >-mike >> >MVP >> > >> >"Jade" <an*******@discussions.microsoft.com> wrote
in >> message >> >news:12****************************@phx.gbl... >> >> 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. >> > >> > >> >. >> > > > >. >
.
The runtime error is from JScript most likely.
var sessionServer = "\\ze483z\TestSession\"; is not a valid string literal.
-mike
MVP
"Jade" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl... I'm sorry, Mike. I still don't know where to put "this.DataBind();" I put it in private void Page_Load(object sender, System.EventArgs e) { this.DataBind(); }
and I still have the runtime error.
-----Original Message----- It did interpreted correctly in HTML: var sessionServer = "\\ze483z\TestSession\";
Right, and that's not valid for JScript, thus the runtime error. where/how should I use "this.DataBind();" exactly in Onload???
this.DataBind(); // That's it
That binds all the <%# markers.
-mike MVP
>-----Original Message----- >Check out HTML output. If you have \\ characters, they will get interpreted >by C#. Try with your variable as "Hello, JScript!" :). > >Using the <%# syntax, did you do a this.DataBind(); call in your OnLoad or >somewhere? > >-mike >MVP > ><an*******@discussions.microsoft.com> wrote in message >news:14****************************@phx.gbl... >> It still doesn't work. Here is exactly what I have now: >> >> <script language="javascript"> >> var sessionServer = "<%=jsTestServer%>"; >> alert(sessionServer); >> >> function CreateSessionFlag() >> { >> alert("hello"); >> } >> >> function DeleteSessionFlag() >> { >> alert("bye"); >> } >> </script> >> </head> >> <body MS_POSITIONING="GridLayout" >> onLoad="CreateSessionFlag();"> >> >> In the C# code behind: >> public class WebForm1 : System.Web.UI.Page >> { >> public string jsTestServer >> = "\\\\ze483z\\TestSession\\"; >> >> private void Page_Load(object sender, System.EventArgs >> e) >> { // Put user code to initialize the page here } >> >> It's a very simple test program. After I changed to "<% >> =jsTestServer%>", it generates some jscript error - >> object expected on the "onload" line. If I used the old >> way var sessionServer = "<%#jsTestServer%>"; it pops up >> an alert with empty message. >> >> >> >-----Original Message----- >> ><%# is the DataBinding syntax. You need to make sure >> you call DataBind() on >> >your page (in the server code. You can also use <% >> =someVariable%>, which >> >will print the value out when it runs. The DataBind way >> is a little more >> >elegant, I feel. >> > >> >-mike >> >MVP >> > >> >"Jade" <an*******@discussions.microsoft.com> wrote in >> message >> >news:12****************************@phx.gbl... >> >> 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. >> > >> > >> >. >> > > > >. >
.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Sue |
last post by:
After finishing up my first quarter JavaScript on 12/12/03, I decided
to improve character checking on my project. In my project I only had
to do very basic validation. Therefore, I only had one...
|
by: cheezebeetle |
last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when...
|
by: Jade |
last post by:
I saw some web page saying I could do it this way in
javascript:
var iNumber = <%#publicvarname publicpropertyname %>
but it doesn't seem to work. I have this piece of code
here in...
|
by: abcd |
last post by:
I am novice asp.net programmer.
I have xyz.js file which has resuable functions. I have asp.net form
abcd.aspx and the code behind file abcd.aspx.cs, I want to put a 'Help'
button when clicked...
|
by: KaNos |
last post by:
Hi,
"robot script pages" are html+javascript pages, can be played in aspx
player. So in this tech, robot call aspx player's function (an interface is
sheared) and wait a result synchronously with...
|
by: hibaru |
last post by:
Hi
Is it possible to call a javascript function from a treeview controls
OnSelectedNodeChanged event? Something similar to a OnClientClick event
for buttons? I cant seem to find anyway to do...
|
by: verci |
last post by:
Hi guys,
I'm running asp.net 2.0.
Does anyone know how to fire or call a javascript function from inside my
(VB.aspx) code without assigning it to a control attribute?
thank you
|
by: moni |
last post by:
Hi..
I am trying to use javascript for google maps display.
If I call the javascript function from my aspx file I use:
<input type="text" id="addresstext" value="Huntington Avenue,...
|
by: supin |
last post by:
hi,
i work in asp.net2.0/c#.not much expert in javascript.i have a variable declared in the c# code behind page.assume the variable contains some value.
i have a javascript function in the...
|
by: Ty |
last post by:
Hello all,
I am creating a web site with Visual Stuido 2008. I am trying to use
a java script file to create a busybox for login from this page
http://blogs.crsw.com/mark/articles/642.aspx.
I...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |