473,406 Members | 2,707 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,406 software developers and data experts.

controls getting values from another control---within a control

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
1 1168
Hi, DC Gringo,

My preferred approach is to create an interface and then implement it in all
page classes that have the mentioned controls in them. In your case the
interface will have one method in it:

Public Interface IPageWithHeaders
Public Sub SetLabelText(ByVal text As String)
End Interface

Then in the implementation in each page class you will access the control in
sectionHeader (the recommended way is to expose the sectionHeaderLabel.Text
as public string property of the sectionHeader class) and set its value to
the value of the passed parameter.

In topHeadline you will cast the Page property to your interface and call
the method:

DirectCast(Me.Page, IPageWithHeaders).SetLabelText(someValue)

Hope this helps
Martin
"DC Gringo" <dc******@visiontechnology.net> wrote in message
news:ei**************@TK2MSFTNGP12.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

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

Similar topics

3
by: Jen | last post by:
Hi I have created some controls (HtmlInputText, HtmlGenericControl, TextBox) dynamically. But I have problem getting the values from these controls to save them. Is there a way to do that? ...
1
by: abjork | last post by:
I have a aspx page with two user controls. One of them holds some properties that I would like to set from the other user control. How do I do that I keep getting "Object reference not set to an...
3
by: Moojjoo | last post by:
I created an user control (.ascx file) with a DropDownList (DDL) with the following code behide: public string Selected_dept_value() { string dept_value = dept_dropdown.SelectedValue; return...
2
by: Leeor Chernov | last post by:
Hi I am using a <asp:Table> in a user control I created and in the loop of inserting another user control( a custom Calendar) to the TableCell by the code:...
2
by: Kiran Kumar Pinjala | last post by:
Hi, May be this is silly, or I just need a second pair eyes to look at this. I am trying to get values that I have edited in a datagrid and update the values with those values. Here is the code...
3
by: Michael Glass | last post by:
I'm working on an ASP.Net web app using VS2005 and the .Net 2.0 framework, and I have a serious problem with the page I'm currently working on. The page has, among other things, two FormViews and a...
8
by: MattB | last post by:
I have a asp.net 1.1/vb application that has a page with a bunch of dynamically added User Controls. When I add the controls, I set the UserControl.EnableViewState to true. For all my controls...
2
by: | last post by:
I want to use codebehind to pass property values to a control that I've embedded INSIDE of a user control. In other words, let's say I have the following: MyPage.aspx ....with the following...
1
by: Roffers | last post by:
Okay I have a parent page, we'll call it parent.aspx and it holds the following two user controls <uc1:Box1 id="Box1" runat="server"></uc1:Box1<----THIS CONTAINS A DROP DOWN LIST <br>...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
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,...
0
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...
0
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...
0
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,...

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.