473,698 Members | 2,250 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reference a user controls properties from another user control??

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.Ma rket =
Nov 18 '05 #1
1 2064
First of all, a UserControl should be an atomic object. By referencing
properties of another user control (that you THINK will be on the page) from
a user control, you are eliminating the possibility of using this user
control on another page by itself, and the benefit of encapsulating content
and code is gone. However, this is how you do it.

From within the user control:
((UserControlTy pe)Page.FindCon trol("idForUser Control")).Prop erty = value;

just switch the syntax to VB. Page.FindContro l(". . .") is what you are
looking for.
-Jeffrey Palermo
"abjork" <an*******@disc ussions.microso ft.com> wrote in message
news:82******** *************** ***********@mic rosoft.com...
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 d
....
formStandard.Ma rket = 4

Nov 18 '05 #2

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

Similar topics

0
1347
by: Mohandas P.M | last post by:
Hi, We have a prob with .Net User Controls, something like this. I have a Custon Control InfoLabel Derived from System.Windows.Forms.Label ( Direct Inheritance - Custom Control) and the some properties of this is held in one custon Class. By setting TypeConverter attribute to the above class we could make it the subproperty. AS a singale control its working fine. Now, We have created another User Control, InfoMultiLabel, that uses this...
1
3017
by: Martine | last post by:
Hi there! I have a problem with programmatically adding user controls to my mobile webforms. If I load my usercontrol programmatically (in the Page_Load), the object is instantiated, I have access to the methods and properties from the Page_Load, no problem there. But as soon as I want access to the user control from another procedure on the same page, I get the next error message: "Object reference not set to an instance of an...
4
2439
by: Josh Harris | last post by:
Here is my question: It is common to have many pieces of business logic encapsulated within asp.net user controls. This can be found in high visibility projects such as the iBuySpy portal from MS. Virtually every bit of the site is encapsulated within user controls. The problem begins when you try to have user controls pass information to one another as well as to their parent form. This can be accomplished by creating public...
1
3369
by: Earl Teigrob | last post by:
Background: When I create a ASP.NET control (User or custom), it often requires security to be set for certain functionality with the control. For example, a news release user control that is comprised of a DataGrid may have separate permissions for adding, deleting and updating a news item. Problem Up until now, I have been implementing security directly inside the control. I will test directly against the security model to see if...
2
2353
by: Jon Hyland | last post by:
This might be a dumb question, but what is the best way for one instance of a user control to access properties of an instance of another user control? For example, let's say I have an instance of UserControlA (ucA1) and an instance of UserControlB (ucB1) on a particular ASP.NET page. UserControlA has a string property called StringA that gets generated from a DB call in it's Page_Load event. I want UserControlB to be able to access...
1
1507
by: Don | last post by:
I created a Web User Control in my project and need to use it in a datagrid. The data in this control needs to be updated and the control has several properties that need to be databound. Using the designer I created a a dataGrid with an Edit, Update, Cancel column, and an empty template column. I have overridden ItemDataBound to instantiate my control, set the properties using DataItems, and add this control to the template column...
8
1873
by: wASP | last post by:
Hi, I'm having a problem referencing the elements within an object after a method of that object (a member function) has been activated with an onsubmit handler: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <script language="javascript" type="text/javascript"> function js_onsubmit_hndl_fn () {
8
1697
by: | last post by:
I'm looking for some design guidance on a collection of projects I'm working on. The project involves a bunch of websites constructed out of a collection of user controls. Different user populations with different access rights and "roles" will be visiting the site. I will be using ASP.NET 2.0's membership, roles, and profiles stuff to manage access. User controls need to be visible or not visible depending on user role. In some...
2
1885
by: Sebastian Paul | last post by:
Hi, I have a user control (EventStructureSelector) used in another user control (ResultsMenu). The class EventStructureSelector defines a public type (ModeType), that is used for one of its properties (Mode). The class ResultsMenu sets the property of the nested control during the PageLoad event. No big thing for now.
0
8675
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
8604
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
9160
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
9029
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...
1
8897
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8862
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
4370
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...
1
3050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2331
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.