How To Access One UserControl from Another UserControl Using ASP.NET
September 2, 2008 Leave a comment
Recently, I came across a post in the asp.net forums (This one > http://forums.asp.net/t/1313476.aspx) , where a user was trying to get the value of a dropdownlist’s selected value kept in one UserControl, and set this value as text of one label which is from another UserControl. I have given the answer and giving here some of the description about the same post.
The Scenario is like; there is one UserControl – 1 in which there is one DropDownList. There is another UserControl – 2 in which there is one Label. In DropDownList’s SelectedIndexChanged event; we need to set the selected value in Label which resied in UserControl – 2.
Everybody knows the purpose of FindControl (Control.FindControl Method (String) (System.Web.UI)) method; it searches the current naming container for a server control with the specified id parameter.
In addition, there is one property called NamingContainer (Control.NamingContainer Property (System.Web.UI)) which Gets a reference to the server control’s naming container, that means it will give the parent container reference of current server control’s…
