Answered by:
Getting User control in User Control from its parent page.

Question
-
User1281761010 posted
I have One user Control on page which is used for displaying error.Every page use that user control for showing Error on that page.It has methods for adding and removing errors.
Question
On One Of My page I have User Control say it as UserControlA(this page also have Error user control).If there is any error occured on UserControlA then I have to get the Error Control present in its parent page for display error.
Cuurently I am Finding the each controls in ContentPlaceHolder of its parent page to get error control from parent page.
Is there any better approach rather than finding each control ContentPlaceHolder ?
Friday, February 26, 2010 9:32 AM
Answers
-
User2130758966 posted
Rather than having to know the name of the ContentPlaceHolder you could make it a bit more generic and use the Parent property of the UserControl:
this.Parent.FindControl("NameOfErrorControl");
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, February 26, 2010 10:49 AM
All replies
-
User2130758966 posted
Rather than having to know the name of the ContentPlaceHolder you could make it a bit more generic and use the Parent property of the UserControl:
this.Parent.FindControl("NameOfErrorControl");
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, February 26, 2010 10:49 AM -
User1281761010 posted
Thanks ...
Friday, February 26, 2010 1:01 PM -
User2130758966 posted
So the error display control is in the content panel? not the masterpage?
Friday, February 26, 2010 2:29 PM -
User1281761010 posted
ya... its Like i have following structure
Master page1 (Common across all pages and viewed only when user is logged in)
Master page2 using Master page1
.aspx page has two user control "ErrorControl" and "UserControlA"(which are inside contentPlaceHolder) and using Master page2
If There is error occured on UserControlA's Page_load() then i have to find ErrorControl(which is user control)on .aspx page to add error messages into it.
Friday, February 26, 2010 2:50 PM