Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User control check for (external) control existence

Status
Not open for further replies.

mjm917

Programmer
Mar 30, 2007
5
US
I am in the process of converting some mark-up & code into a user control. In the original code, a label was being set to display some instructions to the user. This label will exist outside of the user control. How do I refer to it in the uc code?

I tried to check for existence using ...

if ((Label)InstructionsLabel != null)

No good. When I view the page I get ...

CS0103: The name 'InstructionsLabel' does not exist in
the current context

Any and all help would be appreciated.

MJM


 
Everyone -

After taking a break, I came back to this with a clear head... and a solution.

lbl = Page.FindControl("LabelOutsideTheUserControl") as Label;
if (lbl != null)
{
lbl.Text = "";
}

Thought I would post this in case anyone out there is looking for answer as well

MJM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top