Reading a user control from another user control

I have 2 user controls on a page.  The first one (UserControl1) is called "header.ascx".  This contains a drop down list box called "ddlLang".

The other user control (UserControl2) is called "menu.ascx". I want this user control to check the value of "ddlLang" in the header user control.
How do I do it? Quite stuck at the moment!
12/14/2004 10:21:27 PM 93655 articles. 6 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 11
Get it on Google Play
Get it on Apple App Store


even i am stuck to the same problem.
what i came to know is
1) You have to find the page of control....(or if u want to hardcore it say its menuholder.aspx)
2) then u can use menuholder.usercontrol1.findcontrol method to do the require question.....
i am not able to get the page container...of control....

sorry if it is not of ur use...
Nilesh Garg

Nilesh Garg
12/15/2004 5:02:29 AM
Thanks Nilesh, you actually spurred me on to solve this problem.

I added the following to the menu user control:
Dim _ddlName As DropDownList
_ddlName = CType(Page.FindControl("UserControl1:ddlLang"), DropDownList)
Dim lang As String = _ddlName.SelectedItem.Text
And it worked!!!!!
I am no master at this but if you need some help with it just let me know.
12/15/2004 9:32:46 AM
Hey I have done this using and once i get handle of owner of my control I can use ne control from the owner page :)

Nilesh Garg
12/16/2004 7:46:34 AM
Please be aware that while it is possible for user controls to communicate with each other, it should never be done. 

This practice defeats one of the main benefits of User Controls. That is, user controls are self-contained and can be added to any page, regardless of any server controls or user controls that may be on that page.
Instead, it is the Page that should handle any communicate between controls, reading the properties of one control and then calling a method of another control.
If you have your page working, that's great. I'm not suggesting that you change it.
However, for future pages, please keep the above in mind. It may save you some grief.

12/16/2004 9:55:09 AM
Thanks buddy for such a great advice.. we will keep that in mind

Nilesh Garg
12/17/2004 9:09:42 AM

Similar Artilces:

Web User Control to Web User Control...
Hi, I have 2 User controls on a page and want Control1 to call a method of Control2. Is this Possible? Example: Con1 = Datalist showing products, each with a Quantity Box and a Button. Con2 = Repeater showing Cart Preview (name, Price) in page.aspx. When I click on the button on the DataList in Con1 it adds the item into the Session based Cart. However it does not update the Cart Preview. I need to call BindPreview() in Con2 in order to update the Cart Preview... Does that make sense? argh! any help much appreciated! PeteWeb Design Nottingham, UK Well I can call BindPreview() from m...

Web user control inside update panel replace with another web user control
 Hi there. I have a page with a menu. an and then the content. My thing is. That i have the update panel, and inside that i have a regual panel in which i add the Web User Controls i need. Which all works fine. My problem is. That i i have a submit funcion on almoast all the Web User controls. What i would like is that i inside that update panel, can dispose the original Web user Control and then add a response Web User Control. In normal language. Is there a way that i can load one web user control into antoher and then disposose the original? Thanks in advance hello. well, what ...

access controls on web user control x from web user control Y
I have 2 web users controls in a page and I would like to get or set the selected values of a few dropdown boxes on web user control X from web user control Y and I also would like to know how to access functions that are on a web user control X from a web user control Y, is this possible? How can I do it? User can access and set the values of the User Control from .aspx page through properties,using javascript and in code-behind of aspx page.The details of it are shown below Using PropertiesIf the Sample.ascx control has two textboxes and submit button.You can access the valu...

How to access a user control from another user control in a Wizard control
My page has a wizard control and each step is a user control.  I could find the value of a control in step1 user control in the wizard page but not in step2 user control.From wizard.aspx.vb – it worksDim m_title As DropDownList = CType(Me.PersonalBox1.FindControl("ddlTitle1"), DropDownList) Question:How can I find the value of a control(textbox or dropdownlist)in step1 user control from step2 user control? I want to find “PersonalBox1.FindControl("ddlTitle1")” from Step2 AddressBox1. I have tried several ways to access it but no luck. From AddressBox.ascx.vb –...

I have a web user control being used by another web user control, but the one being used will not display the labels in the resx file.
I am using DotNetNuke version 3.13 (might be 3.013) on a Window's XP machine, SP2. I have what I find to be an extremely odd situation. I have a project called TDS.Controls. This project is a web control library. Each control has its own resx file, which is located in the App_LocalResources directory. Each control inherits from Framework.UserControlBase, just like DotNetNuke's User control in DNN\Controls\User.ascx.vb. As a matter of fact, this control is doing the exact same thing I am trying to do. It is a web user control with its own resx file being used by another web user control (See ...

(How) Can i use the form elements of a user control from another user control???
Hi, i have a user control with 4 other user controls. Actually i have 4 panels and each user control is inside a panel. Its like a 4 page form which are all connected to each other. Is it possible to have access to web controls that i have in my user controls from the main user control. In my main user control i have a submit button and a tab list. User can browse through the tabs and each tab is bound to a panel. so clicking on tab1 makes panel1 visible which holds the first user control, second tab makes second panel visible and the rest invisible and the second panel holds the ...

Unable to access user control's user control's function\property from another user control
Hi, I used to call an user control's user control function as stated below from my user control in ASP.Net 1.1 wucCompany.wucEmployee.GetEmployeeSomething() After migrating to ASP.Net 2.0, I am unable to use any properties/functions(even the public ones) of the user control's User control's from another user control.  The way I have to do is create property\function in wucCompany which calls the wucEmployee's property\function and call the wucDepartment.GetEmployeeSomething().Since I need to do this change in too many places, I can...

Updating a Label control in one user control from another user control
Hi all, I have a main page in my music store site that has 5 user controls on it with 1 always showing main content and the others being things like a shopping cart, "best sellers", genre list etc (a la amazon). From the main content control I want to be able to set some label controls in my shopping basket control but I just can't seem to work out the syntax for how to do this: Here's the code I'm using - I'm trying to go to the 4th user control on the page (my shopping basket) then find the appropraite label, cast it locally as a Label then update the value: Label _so...

Problem in accessing web form data in user controls when create user control dynamically
HI. I have a problem using web user control. I designed a user control named NewsForm. This user control contains some web form elements like <asp:textbox>. When I add it in an .ASPX page, all things may be true. I can know which user filles in textbox (for example and other controls) <%@ Register TagPrefix="uc1" TagName="NewsForm" Src="NewsForm.ascx" %> and <UC1:NewsForm id="newsForm" runat="server"></UC1:NewsForm> But when i create it in code behined dynamically, however user control has web form controls but their value are blank for example //aspx co...

Access User Control From another User Control
 ASP.NET 2.0/VB.NET I have a number of pages all with two user controls on them.  I need to access controls/properties from one user control from within another.  I've tried the following from one of the user controls: Dim pg as Page = cType(Me.Page, Page) pg.FindControl("myControl")  'Returns nothing pg.form.findControl("myControl")  'Returns nothing   I also have public properties declared but I can't see those either (I also tried public shared property).  Can anyone help with the syntax?   thanks, Scott ...

Updating a User Control from another User control
I have a web page that has three frames: Header, Nav, and Content. In the header frame, I have a user control for the breadcrumb text (something like "Home : Cases : Jones Case : Contacts") that needs to be updated based on information sent from another user control which is in the Content frame. Is this possible?...

want to call one function in one user control from another user control
hi i have two user controls info.ascx and personal.ascx i have a function like in info.ascx i have a function like showdetails() {   } now i want to access this function from personal.ascx can i do this ? thanks in advance. shwetaThanksshwetaIn a day when don't come across any problem -you can be sure that you are traveling in wrong path  you should better create a class where you will define the "functions" that you need in both files. declare "static" the function and call it like nameofclass.nameoffunction In a web project you can...

UpdatePanel within a web user control resets data of controls outside the user control
Hello, I have a usercontrol on my page which displays a running marquee text. It makes use of an UpdatePanel (within the user control) to refresh the marquee text (within the updatepanel) at periodic intervals. For this I added a timer control and its tick event as an async postback trigger for the UpdatePanel. I have a lot of textboxes and dropdown list boxes (all with runat=server) on the page outside the above user control. These are also contained in different UpdatePanels. Problem is, when the user control does a postback to refresh the marquee text, it causes some of...

User control in a user control
Hello all, I have created a user control with some checkboxes, and public properties to get the values of these checkboxes. I have also created a second user control using the first user control; this second control also access the public properties of the first one. My problem is when I implement the second control in an aspx page, if I click at runtime the checkboxes in the first control, I am able to access its public properties from the methods of the second control but the values of these properties are wrong. while at design time, I do not have this problem. Than...

Web resources about - Reading a user control from another user control -

Open reading frame - Wikipedia, the free encyclopedia
In molecular genetics , an open reading frame (ORF) is the part of a reading frame that contains no stop codons . The transcription termination ...

John Cuningham makes largest ever bequest to Art Gallery of NSW after reading article in The Sydney Morning ...
John Fairlie&nbsp;Cuningham was a&nbsp;regular but little known visitor to the Art Gallery of NSW who ended up surprising the gallery with a ...

Loddon Prison Read Along Dads program: Why criminals are reading Peppa Pig
MIDDLETON sits right next to its older sister, Loddon Prison, in Castlemaine, Central Victoria.

NZ deportee bill passes first reading - PerthNow Search Search
... the New Zealand government to monitor and supervise Kiwis deported from Australia because of their criminal records has passed its first reading ...

CBC Books Reading Lists
Accessibility Links Skip to CBC accessibility page MENU TV Radio News Sports Music Arts Local More Watch Listen Log in SEARCH British ...

Weekend Reading: Ann Pettifor: What Are the Economic Possibilities for Our Grandchildren?
**Ann Pettifor**: [What Are the Economic Possibilities for Our Grandchildren?]( ...

Use AdBlock And Yahoo May Block You From Reading Your E-Mail
If you still live in 2003 and have a Yahoo e-mail account but also use Ad Block to, ya know, block ads, then the folks at Yahoo might have a ...

Persuasion Master Rory Sutherland's Reading List
From being described as the worst graduate trainee that Ogilvy & Mather had every hired, Rory Sutherland took a while to find his calling in ...

Attkisson: Obama Is Selectively Reading Intel Reports
'I have talked to people who have worked in the Obama administration who firmly believe he's made up his mind'

Americans demanding war refugees be turned away are reading from a very old script
... has a long, long history in America. When Chris Christie demands that not even orphaned toddlers be allowed to resettle here, he is reading ...

Resources last updated: 11/25/2015 3:46:24 PM