473,386 Members | 1,753 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,386 software developers and data experts.

passing variables from page to control

I have a simple index.aspx page that declares and sets a sectionID in the
Page_Load. The in a user control later on in the page, I read the sectionID
variable (in the control's Page_Load) to determine which panel to show. It
does not work

"Name 'sectionID' is not declared" is my error while compiling the user
control.

What am I doing wrong?
This is in my main page's Page_Load

Dim sectionID As String = "about"
--
This is in my user control's Page_Load

If sectionID = "about" Then
pnlAbout.Visible = True
ElseIf sectionID = "home" Then
pnlHome.Visible = True
End If
_____
DC G
Nov 18 '05 #1
1 1198
Make a public property or method on your control that accepts the value from
your page. Something like this:

Public Sub SetSection(Section as Integer)
'Now I have the value I need
End Sub

The from your page, call it like this to pass the value along:
MyControlName.SetSectionID(sectionID)

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:OH**************@TK2MSFTNGP09.phx.gbl...
I have a simple index.aspx page that declares and sets a sectionID in the
Page_Load. The in a user control later on in the page, I read the sectionID variable (in the control's Page_Load) to determine which panel to show. It does not work

"Name 'sectionID' is not declared" is my error while compiling the user
control.

What am I doing wrong?
This is in my main page's Page_Load

Dim sectionID As String = "about"
--
This is in my user control's Page_Load

If sectionID = "about" Then
pnlAbout.Visible = True
ElseIf sectionID = "home" Then
pnlHome.Visible = True
End If
_____
DC G

Nov 18 '05 #2

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

Similar topics

4
by: Jason Us | last post by:
Does anyone have experience with passing variables from an ASP page to a JSP page. The way it currently works in passing the SSN in the URL. This cannot be good. I thought that storing a...
7
by: Pete | last post by:
Any ideas on how I can set some data in 1.asp, then have 1.asp do a server.transfer (or .execute, come to that) to 2.asp, and have 2.asp access the original data? I'm aware that the Session...
5
by: Jack | last post by:
Hi, I need to pass multple variables in a link in order to go to a asp page with the two varables. The following are the values of the variables using response.write: <%'Response.Write Mypage...
27
by: Oscar | last post by:
I am looking for a way to pass an ADO recordset that has been retrieved in an ASP page to another HTML-page. Is there someone who can provide me with a small sample or a link to see how this is...
0
by: Omar K | last post by:
Hi, I am quite new to frontpage and SQL but I have a Stock Control access database / frontpage to set up. My last problem deals with the automatic updating of the total quantity of stock with parts...
6
by: Eric Johnston | last post by:
I want the visitor to enter three numbers on the page and then click a button "generate image" which will I hope cause a generated gif image to be displayed alongside on the page. This involved...
2
by: darrel | last post by:
Is there a SOP for setting variables on an ASPX page that the usercontrols on that page can read? I'd like to set a 'template=' variable that various other controls can see (the header,...
3
by: Dan Nash | last post by:
Hi I'm new to C#, moving from ASP, and slightly confused so bear with me! Basically I've got 4 pages, each of which runs the same user control (some header information). I want to be able to...
4
by: Darrel | last post by:
I'm really stuck on the concept of using public variables to pass information between usercontrols. I'm pretty sure I'm just flubbing up the syntax. This is what I want: page usercontrol 1 -...
5
by: Fernando Chilvarguer | last post by:
I'm sure this has come up before but I could not find any post on it. How can I read a variable or property that has been set on a ASPX page from inside a ASCX control. ASPX code: public...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.