473,769 Members | 1,723 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.sec tionHeader1.sec tionHeaderLabel .Text = myVariable

In topHeadlines, I have:

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

(In Page Load): mainHeader1.sec tionHeader1.sec tionHeaderLabel .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 1178
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 IPageWithHeader s
Public Sub SetLabelText(By Val 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 sectionHeaderLa bel.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.P age, IPageWithHeader s).SetLabelText (someValue)

Hope this helps
Martin
"DC Gringo" <dc******@visio ntechnology.net > wrote in message
news:ei******** ******@TK2MSFTN GP12.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.sec tionHeader1.sec tionHeaderLabel .Text = myVariable

In topHeadlines, I have:

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

(In Page Load): mainHeader1.sec tionHeader1.sec tionHeaderLabel .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
1966
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? Regards and Many thanks Jen
1
2074
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 instance of an object." when I declare the first user control like this from within the second UC Public formStandard As PIC.FormStandar .... formStandard.Market =
3
1278
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 dept_value; } All the values were added via the visual interface.
2
1286
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: TableCellObj.Controls.Add(myCustomUserControl) the table accepting this user control but do not render it , so in that way I dont see the control in the table..., I tried also another user control with only html , and It doesnt rendered also How can I fix this bug???? (Note: I...
2
1695
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 that I am using in my update command. TextBox txtProdName = (TextBox)e.Item.Cells.Controls; TextBox txtSuppID = (TextBox)e.Item.Cells.Controls; TextBox txtCatID = (TextBox)e.Item.Cells.Controls;
3
3879
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 GridView control, each with its own SqlDataSource. FormView1 talks to my Opportunity table and has an ItemTemplate and an EditItemTemplate. FormView2 talks to my Activities table and has an ItemTemplate, InsertItemTemplate and an...
8
1572
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 with TextBoxes, I can get the value back out of the controls just fine. One of my User Controls has some DropDownLists as well as a TextBox. I get a value from the TextBox on postback, but not the DropDownLists. Even if I see a value selected when...
2
1562
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 control placed on it... MyUserControl.ascx .... and inside of MyUserControl.ascx, is an instance of .... MyCommercialUploadControl1
1
1679
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> <uc1:Box2 id="Box2" runat="server"></uc1:Box2<----THIS CONTAINS A DATALIST In Box1, I have a dropdown list that gets selected and should set
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8870
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5298
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.