Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > referencing controls in controls

Reply
Thread Tools

referencing controls in controls

 
 
DC Gringo
Guest
Posts: n/a
 
      09-15-2004
I am a bit twisted and need some straightening out. I have a webform with 3
controls on it: a mainHeader, a sectionHeader with a label control contained
in the mainHeader, and a topHeadline.

In the topHeadline, I am retrieving a value with a stored procedure. I need
to set that value to a label control within the sectionHeader like this:

mainHeader1.sectionHeader1.sectionHeaderLabel.Text = myVariable

In topHeadlines, I have:

Public countryName As String
Protected mainHeader1 As mainHeader
Protected sectionHeader1 As sectionHeader

(In Page Load): mainHeader1.sectionHeader1.sectionHeaderLabel.Text =
myVariable

The error I get is: "Object reference not set to an instance of an object."

What am I doing wrong?

_____
DC G



--
_____
DC G



 
Reply With Quote
 
 
 
 
Karl
Guest
Posts: n/a
 
      09-15-2004
Your problem is that topHeadline doesn't know anything about mainHeader1 and
sectionHeader1....they are defined in the page, not topheadline. The trick
is to go through the page.

The page should have

public mainHeader1 as Mainheader
public sectionHeader1 as sectionHeader


your topHeadline should do:

ctype(Page, TYPEOFYOURPAGE).mainHeader1.sectionHeaderLabel.Tex t = myVariable


Also consider doing a pull (making the mainHeader1 get the data from
topheadline) instead of a push (passing the data from topheadline to
mainHeader1). Seems to me you have business logic in your presentation
layer. Whatever this data is that both user controls need should be placed
in a separate class and caching should be used (if appropriate)

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/


"DC Gringo" <(E-Mail Removed)> wrote in message
news:OK2$(E-Mail Removed)...
> I am a bit twisted and need some straightening out. I have a webform with

3
> controls on it: a mainHeader, a sectionHeader with a label control

contained
> in the mainHeader, and a topHeadline.
>
> In the topHeadline, I am retrieving a value with a stored procedure. I

need
> to set that value to a label control within the sectionHeader like this:
>
> mainHeader1.sectionHeader1.sectionHeaderLabel.Text = myVariable
>
> In topHeadlines, I have:
>
> Public countryName As String
> Protected mainHeader1 As mainHeader
> Protected sectionHeader1 As sectionHeader
>
> (In Page Load): mainHeader1.sectionHeader1.sectionHeaderLabel.Text =
> myVariable
>
> The error I get is: "Object reference not set to an instance of an

object."
>
> What am I doing wrong?
>
> _____
> DC G
>
>
>
> --
> _____
> DC G
>
>
>



 
Reply With Quote
 
 
 
 
DC Gringo
Guest
Posts: n/a
 
      09-16-2004
Karl, you're a genius!!! thanks!!
_____
DC G


"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:(E-Mail Removed)...
> Your problem is that topHeadline doesn't know anything about mainHeader1

and
> sectionHeader1....they are defined in the page, not topheadline. The

trick
> is to go through the page.
>
> The page should have
>
> public mainHeader1 as Mainheader
> public sectionHeader1 as sectionHeader
>
>
> your topHeadline should do:
>
> ctype(Page, TYPEOFYOURPAGE).mainHeader1.sectionHeaderLabel.Tex t =

myVariable
>
>
> Also consider doing a pull (making the mainHeader1 get the data from
> topheadline) instead of a push (passing the data from topheadline to
> mainHeader1). Seems to me you have business logic in your presentation
> layer. Whatever this data is that both user controls need should be

placed
> in a separate class and caching should be used (if appropriate)
>
> Karl
>
> --
> MY ASP.Net tutorials
> http://www.openmymind.net/
>
>
> "DC Gringo" <(E-Mail Removed)> wrote in message
> news:OK2$(E-Mail Removed)...
> > I am a bit twisted and need some straightening out. I have a webform

with
> 3
> > controls on it: a mainHeader, a sectionHeader with a label control

> contained
> > in the mainHeader, and a topHeadline.
> >
> > In the topHeadline, I am retrieving a value with a stored procedure. I

> need
> > to set that value to a label control within the sectionHeader like this:
> >
> > mainHeader1.sectionHeader1.sectionHeaderLabel.Text = myVariable
> >
> > In topHeadlines, I have:
> >
> > Public countryName As String
> > Protected mainHeader1 As mainHeader
> > Protected sectionHeader1 As sectionHeader
> >
> > (In Page Load): mainHeader1.sectionHeader1.sectionHeaderLabel.Text =
> > myVariable
> >
> > The error I get is: "Object reference not set to an instance of an

> object."
> >
> > What am I doing wrong?
> >
> > _____
> > DC G
> >
> >
> >
> > --
> > _____
> > 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
Trouble referencing controls within list controls 2obvious ASP .Net 2 01-11-2005 08:42 PM
referencing controls in controls DC Gringo ASP .Net Building Controls 2 09-16-2004 10:40 PM
Trouble referencing controls within list controls 2obvious ASP .Net 0 09-13-2004 10:38 PM
Referencing controls on user controls Jim Corey ASP .Net 1 01-26-2004 07:47 PM
referencing controls tim payne ASP .Net 1 08-28-2003 04:37 PM



Advertisments