473,379 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Sharing variables between <% %> and a function

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.

Apr 5 '06 #1
8 1458
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

<an***********@yahoo.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.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.

Apr 5 '06 #2
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

<an***********@yahoo.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.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.


Apr 5 '06 #3
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

<an***********@yahoo.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.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:
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

<an***********@yahoo.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.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.
>

Apr 5 '06 #4
I guess you don't wanna bother to give a more enlightening example.
Thanks anyway.

Apr 5 '06 #5
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

<an***********@yahoo.com> wrote in message
news:11*********************@u72g2000cwu.googlegro ups.com...
I guess you don't wanna bother to give a more enlightening example.
Thanks anyway.

Apr 5 '06 #6
<%@ 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>

<an***********@yahoo.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.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.

Apr 5 '06 #7
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>

<an***********@yahoo.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.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.


Apr 5 '06 #8
This was your code...

<param name="fileName" value="<%= myString %>">
--
Robbe Morris - 2004-2006 Microsoft MVP C#
Earn money answering .NET questions
http://www.eggheadcafe.com/forums/merit.asp

<an***********@yahoo.com> wrote in message
news:11********************@u72g2000cwu.googlegrou ps.com...
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>

<an***********@yahoo.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.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.
>

Apr 5 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Christian Schmidbauer | last post by:
Hello! I prepare my XML document like this way: ------------------------------------------------------- PrintWriter writer; Document domDocument; Element domElement; // Root tag
9
by: Rolf Kemper | last post by:
Dear Experts, I got stuck with the following problem and need your help. What I wnat to do is to get a set of distinct nodes. Before the distinct I have selected the multiple occourences...
2
by: Donald Firesmith | last post by:
I am having trouble having Google Adsense code stored in XSL converted properly into HTML. The <> unfortunately become &lt; and &gt; and then no longer work. XSL code is: <script...
6
by: Lasse | last post by:
I have done this simple function, it seems to work as intended, to solve a problem i have had for a while. I couldnt find any sample around that was working for me. I would like to test it with...
4
by: higabe | last post by:
Three questions 1) I have a string function that works perfectly but according to W3C.org web site is syntactically flawed because it contains the characters </ in sequence. So how am I...
5
by: Vinu | last post by:
Hi I am facing a problem in compilation the error is like this In constructor xServices::CServices<TImp>::StHoldClientList::StHoldClientList(std::set<TImp*, std::less<TImp*>,...
11
by: Les Paul | last post by:
I'm trying to design an HTML page that can edit itself. In essence, it's just like a Wiki page, but my own very simple version. It's a page full of plain old HTML content, and then at the bottom,...
10
by: EOZyo | last post by:
Hi, i'm trying to set pagination for a search i run on my website, i'll try to explain the easiest i can: When i click the search button on search.php, data is received and stored in variables...
14
by: Motion Musso aka: Sathia | last post by:
Hi, I'm trying to have two input field ie: who |mickey mouse| <- value is "mickey mouse" when |12...| |12-5-2005|
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.