help for enabled property
-
There are some set of server controls its property enabled= may be true or false,now in code behind how to find its current state and i am getting the controls id during runtime like this foreach(Control c in form1.Controls) { ............ } and also there is no property like (c.Enabled) to check
Thanks In Advance
-
There are some set of server controls its property enabled= may be true or false,now in code behind how to find its current state and i am getting the controls id during runtime like this foreach(Control c in form1.Controls) { ............ } and also there is no property like (c.Enabled) to check
Thanks In Advance
vamsimohan21 wrote:
foreach(Control c in form1.Controls) { ............ }
A web form has a Controls collection, the trick is that it's a tree, so you need to recurse over it.
Christian Graus - C++ MVP
-
vamsimohan21 wrote:
foreach(Control c in form1.Controls) { ............ }
A web form has a Controls collection, the trick is that it's a tree, so you need to recurse over it.
Christian Graus - C++ MVP
Thank sir for that and i tried with that but not got any solution can u just pls tell me any sample code and also how to know whether the control is enabled or in disabled state during runtime
Thanks In Advance
-
Thank sir for that and i tried with that but not got any solution can u just pls tell me any sample code and also how to know whether the control is enabled or in disabled state during runtime
Thanks In Advance
Web controls do in fact have an Enabled property. I just checked. Maybe you need to post your code ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
-
Web controls do in fact have an Enabled property. I just checked. Maybe you need to post your code ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog
protected void Button1_Click1(object sender, EventArgs e) { foreach(Control c in mainform.Controls) { if (String.Compare(c.GetType().ToString(), "System.Web.UI.LiteralControl") == 1) { (//HERE I HAVE TO CHECK WHETHER THE CURRENT CONTROL IS IN ENABLED/DISABLED STATE) if (c.Enabled) //Error 4 'System.Web.UI.Control' does not contain a definition for 'Enabled' C:\Documents and Settings\vamsi\My Documents\Visual Studio 2005\WebSites\WebSite1\Default.aspx.cs 86 23 C:\...\WebSite1\ { ................. } } } The above is the error i am reciving sir
THANKS IN ADVANCE
-
protected void Button1_Click1(object sender, EventArgs e) { foreach(Control c in mainform.Controls) { if (String.Compare(c.GetType().ToString(), "System.Web.UI.LiteralControl") == 1) { (//HERE I HAVE TO CHECK WHETHER THE CURRENT CONTROL IS IN ENABLED/DISABLED STATE) if (c.Enabled) //Error 4 'System.Web.UI.Control' does not contain a definition for 'Enabled' C:\Documents and Settings\vamsi\My Documents\Visual Studio 2005\WebSites\WebSite1\Default.aspx.cs 86 23 C:\...\WebSite1\ { ................. } } } The above is the error i am reciving sir
THANKS IN ADVANCE
vamsimohan21 wrote:
if (String.Compare(c.GetType().ToString(), "System.Web.UI.LiteralControl") == 1)
What on earth is this ? It's a mess. if (c is LiteralControl) { // etc }
vamsimohan21 wrote:
//Error 4 'System.Web.UI.Control' does not contain a definition for 'Enabled'
Perhaps you need to have a derived class to have that property ? LiteralControl lc = c as LiteralControl; if (lc != null & lc.Enabled) { // Whatever } This still won't work, unless you just didn't bother to post the code that causes it to be recursive, but I don't see how it can be.
Christian Graus - C++ MVP