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

referencing controls in controls

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

Nov 18 '05 #1
2 1064
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" <dc******@visiontechnology.net> wrote in message
news:OK**************@TK2MSFTNGP15.phx.gbl...
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

Nov 18 '05 #2
Karl, you're a genius!!! thanks!!
_____
DC G
"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:eS**************@TK2MSFTNGP15.phx.gbl...
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" <dc******@visiontechnology.net> wrote in message
news:OK**************@TK2MSFTNGP15.phx.gbl...
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


Nov 18 '05 #3

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

Similar topics

3
by: shumaker | last post by:
This code from the subform works for getting the value of a field of the main form named "WorkSheet": MsgBox Form_WorkSheet.Recordset.Fields("Clerk").Value Each record in the mainform datasheet...
4
by: mplogue | last post by:
I have a form (frmMain) with a subform (frmSub), each with enumerated fields of the same name (txt1, txt2, etc). I'm trying to make a function that will take the values for each field in frmMain,...
3
by: 2obvious | last post by:
I have a DataGrid containing a TextBox control and a CustomValidator in each row. The CustomValidator fires a function that compares all TextBoxes for equality. The algorithm for comparison is...
1
by: Felipe Garcia | last post by:
Does makes difference referencing controls inside EVERY page <%@ Register TagPrefix="PC" Namespace="MyControls" Assembly="Personal.MyControls" %> or referencing controls ONCE inside web.config,...
3
by: Lyners | last post by:
I have a table within a cell of a datagrid. I am doing updates without postback to the server using Javascript. I have everything working, except referencing a table within the datagrid cell. ...
2
by: Axel | last post by:
Hi, a question about something that seems very simple at first glance: is it possible to reference other controls of a subform in a query window without referencing through the parent form? I...
21
by: cmd | last post by:
I have code in the OnExit event of a control on a subform. The code works properly in this instance. If, however, I put the same code in the OnExit event of a control on a Tab Control of a main...
2
by: ccsnavy | last post by:
For some reason referencing an unbound control on an active form from a query has ceased to work correctly. While other previously existing references to unbound controls in the same form seem to...
5
kcdoell
by: kcdoell | last post by:
Good Morning: I am using the following code to add new records to a table that is on my Sub Form. Below is the code that I placed in my Before Update event on my Sub Form: Private Sub...
2
by: =?Utf-8?B?SmFtZXMgUGFnZQ==?= | last post by:
Hi all I have a user control - mycontrol.ascx with various controls within it. mycontrol.ascx is utilised in myPage.aspx I have a class (class1) to carry out various functions, subs etc. How...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.