//Code inside of a UserControl, appearing on a page that
//has "literalParentError" used for displaying errors
//to the user.
//Code that might break...
//Provide the below error to the user
Literal literalError = (Literal)this.Parent.FindControl("literalParentError");
literalError.Text = (string)GetGlobalResourceObject("GRO_File", "Err_AppBroke");
The above allows for the means of a UserControl (.ascx) changing text located on its parent's page (.aspx). I found a question post from erik little having difficulties that lead to the above solution.
Where is this useful?I needed it for multiple forms that users would fill out. I had one page that displayed different UserControls based on an earlier user selection. If any errors occurred, I wanted them to be displayed consistently across the board. Rather than editing all of the forms' UserControls each time a UI change was requested, a single change on the parent page saves time.
A search function UserControl could use this method of error display to keep consistency across entire site sections, yet still use the same code.
Post a Comment