I need to set text property for any type controls(Ex. Textbox,Label,HyperLink..etc) from my web page dynamically. Here is my code
foreach (string id in List<IdCollection>)
{
Control ctrl = (this.Page.FindControl(id)); // Control should be HtmlGenericControl or WebControl.
ctrl.Text=???(This property is not available for Control Class)..
}
I dont need to check each and every control type for set text property as like as following codes
if(ctrl is TextBox)
{
((TextBox)ctrl).Text="test";
}
or
if(ctrl.GetType()==typeof(TextBox))
{
((TextBox)ctrl).Text="test";
}
Is there any other way to set text property as simple, just like as the following code
WebControl wbCntrl=(WebControl)ctrl;
wbCntrl.Tooltip="tooltip"; //// This is possible
wbCntrl.Text="test" ??? //// But this is not possible
Thanks