Hi, gurus:
For VB.NET, if I have a variable myString somewhere inside <% and %>
in a page called mypage.aspx like so:
<%
'... some code here
myString = "Junkie.txt"
'... some other code here
%>
My client side code will use 'myString' like this:
<param name="fileName" value="<%= myString %>">
Now can I also have a function in the same page and have the function
use myString? In other words, can I have something like below in
mypage.aspx?
Sub mySub()
lblMessage.Text = myString
End Sub
Assuming that lblMessage is a Label control declared in mypage.aspx.
When I was trying to do this, the compiler says that 'myString' is not
declared.
Did I make the idea clear? How to implement it? Thanks.declare it at class level either as protected or public
Robbe Morris - 2004-2006 Microsoft MVP C#
Earn money answering .NET questions
http://www.eggheadcafe.com/forums/merit.asp
<antonyliu2002@.yahoo.com> wrote in message
news:1144197959.873242.242800@.i40g2000cwc.googlegroups.com...
> Hi, gurus:
> For VB.NET, if I have a variable myString somewhere inside <% and %>
> in a page called mypage.aspx like so:
> <%
> '... some code here
> myString = "Junkie.txt"
> '... some other code here
> %>
> My client side code will use 'myString' like this:
> <param name="fileName" value="<%= myString %>">
> Now can I also have a function in the same page and have the function
> use myString? In other words, can I have something like below in
> mypage.aspx?
> Sub mySub()
> lblMessage.Text = myString
> End Sub
> Assuming that lblMessage is a Label control declared in mypage.aspx.
> When I was trying to do this, the compiler says that 'myString' is not
> declared.
> Did I make the idea clear? How to implement it? Thanks.
>
Hey, Robbe,
Thanks for your hint. But I am new to VB.NET. I used to do Java.
Would you mind giving me an example, such as below?
Class MyClass
Dim Public myString As String
blah blah blah
End Class
And then how to use it? My mind is chaotic about this stuff.
Robbe Morris [C# MVP] wrote:
> declare it at class level either as protected or public
> --
> Robbe Morris - 2004-2006 Microsoft MVP C#
> Earn money answering .NET questions
> http://www.eggheadcafe.com/forums/merit.asp
>
>
> <antonyliu2002@.yahoo.com> wrote in message
> news:1144197959.873242.242800@.i40g2000cwc.googlegroups.com...
Just like you did in your previous post.
Robbe Morris - 2004-2006 Microsoft MVP C#
Earn money answering .NET questions
http://www.eggheadcafe.com/forums/merit.asp
<antonyliu2002@.yahoo.com> wrote in message
news:1144199819.666284.140550@.g10g2000cwb.googlegroups.com...
> Hey, Robbe,
> Thanks for your hint. But I am new to VB.NET. I used to do Java.
> Would you mind giving me an example, such as below?
> Class MyClass
> Dim Public myString As String
> blah blah blah
> End Class
> And then how to use it? My mind is chaotic about this stuff.
> Robbe Morris [C# MVP] wrote:
>
I guess you don't wanna bother to give a more enlightening example.
Thanks anyway.
I think part of the problem is the appearnace of the question to be so lame
as a "former Java developer" you should just write the one line of code and
see if it works yourself.
<%= Clinton Gallagher
<antonyliu2002@.yahoo.com> wrote in message
news:1144201455.679837.20390@.u72g2000cwu.googlegroups.com...
>I guess you don't wanna bother to give a more enlightening example.
> Thanks anyway.
>
<%@. Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Public myString
Sub mySub()
lblMessage.Text = myString
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<%
myString = "Junkie.txt"
mySub()
%>
<param name="fileName" value="<%= myString %>">
<asp:label id="lblMessage" runat="server" text="Label"></asp:label>
</div>
</form>
</body>
</html>
<antonyliu2002@.yahoo.com> wrote in message
news:1144197959.873242.242800@.i40g2000cwc.googlegroups.com...
> Hi, gurus:
> For VB.NET, if I have a variable myString somewhere inside <% and %>
> in a page called mypage.aspx like so:
> <%
> '... some code here
> myString = "Junkie.txt"
> '... some other code here
> %>
> My client side code will use 'myString' like this:
> <param name="fileName" value="<%= myString %>">
> Now can I also have a function in the same page and have the function
> use myString? In other words, can I have something like below in
> mypage.aspx?
> Sub mySub()
> lblMessage.Text = myString
> End Sub
> Assuming that lblMessage is a Label control declared in mypage.aspx.
> When I was trying to do this, the compiler says that 'myString' is not
> declared.
> Did I make the idea clear? How to implement it? Thanks.
>
Thanks a lot. This code snippet is great! I got the idea now.
Ken Cox - Microsoft MVP wrote:
> <%@. Page Language="VB" %>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <script runat="server">
> Public myString
> Sub mySub()
> lblMessage.Text = myString
> End Sub
> </script>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitled Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <%
> myString = "Junkie.txt"
> mySub()
> %>
> <param name="fileName" value="<%= myString %>">
> <asp:label id="lblMessage" runat="server" text="Label"></asp:label
> </div>
> </form>
> </body>
> </html>
> <antonyliu2002@.yahoo.com> wrote in message
> news:1144197959.873242.242800@.i40g2000cwc.googlegroups.com...
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment