473,785 Members | 2,879 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

<asp:label> with the same text value....

I want an "order number" to be displayed more than once
on my page.

<script language="vb" runat="server">
...
dim ordernumber as string = "123456"
page.databind()
...
</script>

<p>text text text</p>
<asp:label runat="server" text='<%# ordernumber %>' />
<p>more text more text</p>
<asp:label runat="server" text='<%# ordernumber %>' />
<p>The order number could be displayed in other places on
the page as well.</p>

My error is "Name 'ordernumber' is not declared"

Is this the right way to do this? Some help would be
greatly appreciated!

Thanks,
John
Nov 19 '05 #1
5 1425
"Johnb41" <or****@informa tik.com> wrote in message
news:0c******** *************** *****@phx.gbl.. .
I want an "order number" to be displayed more than once
on my page.

<script language="vb" runat="server">
...
dim ordernumber as string = "123456"
page.databind()
...
</script>

<p>text text text</p>
<asp:label runat="server" text='<%# ordernumber %>' />
<p>more text more text</p>
<asp:label runat="server" text='<%# ordernumber %>' />
<p>The order number could be displayed in other places on
the page as well.</p>

My error is "Name 'ordernumber' is not declared"

Is this the right way to do this? Some help would be
greatly appreciated!


Where did you put that script? What is the scope of ordernumber? It's the
subroutine that "dim" line is in, and doesn't include the entire page.

You need to declare such a thing at page level.

Since I never use server-side script in a .aspx file, I can't tell you how
to do this that way. If you were using codebehind, I'd tell you to put:

Protected ordernumber As String = "123456"

outside of any subroutine.
John Saunders
Nov 19 '05 #2
Thanks, it works when i declare the variable outside any sub routine.
However, in my real page, the order number is grabbed from a hashtable
item. I ran into a more serious problem that i wasn't able to fix...
but i found a sufficient workaround.

Inside my sub routine, i set the hashtable item (the order number) to
be a session variable:

session("ordern umber") = hashtable("Orde rNumber")

Then for the label, i did:

<asp:label runat="server" text='<%# session("OrderN umber") %>' />

Probably not the best solution, but it's good enough for me.
Thanks again for your help!

John

Nov 19 '05 #3
"johnb41" <or****@informa tik.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
Thanks, it works when i declare the variable outside any sub routine.
However, in my real page, the order number is grabbed from a hashtable
item. I ran into a more serious problem that i wasn't able to fix...
but i found a sufficient workaround.

Inside my sub routine, i set the hashtable item (the order number) to
be a session variable:

session("ordern umber") = hashtable("Orde rNumber")

Then for the label, i did:

<asp:label runat="server" text='<%# session("OrderN umber") %>' />

Probably not the best solution, but it's good enough for me.


Why not just declare the Hashtable outside of any sub, then reference it in
the databinding expression like you're now doing with session?

John Saunders
Nov 19 '05 #4
That was the problem that i wasn't able to figure out.

I added this line outside all sub routines:

Dim Hashtable_Order Info as new Hashtable(Ctype (Session("Order Info"),
Hashtable))

A little history: The previous page added items to the hash table. To
bring this info to the next page, i put the hashtable info into a
session variable. Then on the next page i converted the session
variable back into a hashtable (using the line of code above).

The code works perfectly fine inside of a sub routine, but when it's
outside of a routine, i get an error saying that i cannot use a session
variable. The error gives me advice on how to fix it, but it still
gives me the same error. I ran across this problem a couple days
ago... after a full day of frustration, i gave up. So when this error
came up today, I just didn't want to deal with it!

John

Nov 19 '05 #5
"johnb41" <or****@informa tik.com> wrote in message
news:11******** **************@ c13g2000cwb.goo glegroups.com.. .
That was the problem that i wasn't able to figure out.

I added this line outside all sub routines:

Dim Hashtable_Order Info as new Hashtable(Ctype (Session("Order Info"),
Hashtable))

A little history: The previous page added items to the hash table. To
bring this info to the next page, i put the hashtable info into a
session variable. Then on the next page i converted the session
variable back into a hashtable (using the line of code above).

The code works perfectly fine inside of a sub routine, but when it's
outside of a routine, i get an error saying that i cannot use a session
variable.


Could you please post the error message?

Also, try doing the above step by step so you can see what step it failed
at. Try changing the hashtable to:

Protected Hashtable_Order Info As Hashtable()

and then, at the end of OnInit (or Page_Init, if that's how VB.NET does
things):

Dim ht As Hashtable = DirectCast(Sess ion("OrderInfo" ), Hashtable)
Hashtable_Order Info = New Hashtable(ht)

(use DirectCast when you know what the source type is, and you don't need it
converted to another type - you just need the actual source type
acknowledged)

John Saunders
Nov 19 '05 #6

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

Similar topics

1
2181
by: RSB | last post by:
Hi Every one, Having tuff time to make this work .. i want to have a button and on my form say Delete button. So once i click on it i want to confirm "Are you sure?" on the Client Side and if client select "Cancel" then i want to ignore the action and if "OK" selected then i want to Execute a Server side Event or Procedure. Now what is happening here is for "Delete1" button (in my code) even if Client Select Cancel it is still...
1
1592
by: John Smith | last post by:
I created a dataTable that returns a value from a stored procedure. How would I bind that results of a query to an <asp:label>? Thank you!
6
2932
by: Andreas Klemt | last post by:
Hello, when I use <asp:label font-size="16px" text="Hello World" runat="server" /> and run FireFox Browser the output of "Hello World" is not in Size 16px. The size will be ignored and I can not find it in the HTML Source Code. Why is it a problem with FireFox and what is the solution how to set sizes in Labels?
3
3455
by: nick | last post by:
Is possible for server side code to access the text of <asp:label> changed by client side javascript code?
2
1530
by: xzzy | last post by:
I need to update the .Text of a label until the user logs out. but get this error: Error: Method name expected I have listed the code below and the offending line of code is delimited by //The next line breaks: Error: Method name expected
4
1363
by: mark.norgate | last post by:
Why oh why does my <asp:labelrevert to its initial value, having been changed programmatically, when I click a button in a user control I have added dynamically to the page? It's EnableViewState is set to true. Mark
7
1825
by: Smokey Grindle | last post by:
How can you correctly use the <labelelement in asp.net? does the label custom control corelate to this tag correctly in the same way in that if you click it it will select the tied element? thanks
8
4524
by: gelligokul | last post by:
Hello frens i want to retrieve <asp:label> value from the code behind in c# can any one help me...
3
2574
by: Homer J. Simpson | last post by:
I have the following stored procedure: ALTER PROCEDURE . AS BEGIN SET NOCOUNT ON; SELECT COUNT(*) FROM QUICKNOTES END ....and the following data source in my .aspx file:
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10152
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8974
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3650
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.