Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > passing variables from page to control

Reply
Thread Tools

passing variables from page to control

 
 
DC Gringo
Guest
Posts: n/a
 
      05-27-2004
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


 
Reply With Quote
 
 
 
 
Steve C. Orr [MVP, MCSD]
Guest
Posts: n/a
 
      05-27-2004
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" <> wrote in message
news:...
> 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
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Put variables into member variables or function variables? tjumail@gmail.com C++ 9 03-23-2008 04:03 PM
Passing variables from ASPX page to ASCX control Fernando Chilvarguer ASP .Net 5 09-01-2006 01:16 AM
passing variables to a user control =?Utf-8?B?RGFuIE5hc2g=?= ASP .Net 3 10-07-2004 10:25 AM
User Controls Passing Variables from one control to another Philip Poole ASP .Net 3 09-23-2004 02:02 PM
passing variables from aspx page to ascx control darrel ASP .Net 2 05-21-2004 03:55 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57