Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Enumerate controls
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00705640
Message ID:
00707754
Views:
20
In addition to what Mike suggested, it seems like Webform has different collections for HTML and ASP.NET controls. So if you iterate through form.controls(), it will not include all controls on the webform. So, I had to make recursive calls just like this.
public void SetMode(ControlCollection toControls,bool tlMode)
{
foreach (Control loControl in toControls)
{
if(AllFunction.At("dropdownlist",loControl.GetType().ToString().ToLower()) > 0)
{
((DropDownList) loControl).Enabled = tlMode;
continue;
}

if(AllFunction.At("textbox",loControl.GetType().ToString().ToLower()) > 0)
{
((TextBox) loControl).Enabled = tlMode;
continue;
}
if (loControl.HasControls())
{
this.SetMode(loControl.Controls,tlMode);
}
}
}
>Cool. What would be the enumeration model. The [for each ... Next] I had below does NOT go through all the controls. :) And what Imports do I use to get access to .AT() as it does not seem to be a default. It looks as if MyFunctions is a UDC (user defined class)
>
>Thanks again,
>
>>
>>if(MyFunctions.At("dropdownlist",loControl.GetType().ToString().ToLower()) > 0)
>>{
>>//It's a dropdown...
>>}
>>
>>
>>MyFunctions.At works just like Foxpro's At().
>>
>>>how do I enumerate controls on a webform?
>>>
>>>'' What doesn't work;
>>>dim ctl as control
>>>for each ctl in ?webform?
>>>    if (type of ctl is textbox) then
>>>        'do something with textboxes
>>>    end if
>>>    if (type of ctl is blah) then
>>>        'do something with blah etc
>>>    end if
>>>next
>>>
>>>
>>>Thanks in advance,
- Jayesh
Previous
Reply
Map
View

Click here to load this message in the networking platform