I am trying to go through all controls in a page and if its a text box then making it non editable.... how do i go about it...
Finding Controls in a Page
Collapse
X
-
Tags: None
-
I am trying to do something like this... but their is no option as where to match the control if its a text box....??
foreach (Controls control in Page.Controls)
{
if control.?? = textbox
{
}
}Comment
-
The system is not giving my any option when I put a . after c.....
when i try this
if(c.??? I get nothing.... have you tried this on your system???Comment
-
Did you note this line change?Originally posted by mayankaswalThe system is not giving my any option when I put a . after c.....
when i try this
if(c.??? I get nothing.... have you tried this on your system???
Code:foreach (Controls c in Page.Controls)
Comment
-
When I type in your code
foreach (Controls c in Page.Controls)
{
if (c.GetType() == typeof(TextBox) )
{
// No Statements here till now
}
}
It gives me followiing error.....
........Control s' is a 'namespace' but is used like a 'type'
The type or namespace name 'TextBox' could not be found (are you missing a using directive or an assembly reference?)Comment
-
OOPS! That is my fault!Originally posted by mayankaswalWhen I type in your code
foreach (Controls c in Page.Controls)
{
if (c.GetType() == typeof(TextBox) )
{
// No Statements here till now
}
}
It gives me followiing error.....
........Control s' is a 'namespace' but is used like a 'type'
The type or namespace name 'TextBox' could not be found (are you missing a using directive or an assembly reference?)
Code:foreach (Control c in Page.Controls)
Comment
-
The type or namespace name 'Control' could not be found (are you missing a using directive or an assembly reference?)
The type or namespace name 'TextBox' could not be found (are you missing a using directive or an assembly reference?)
Maybe it will work... I guess...:)
where do I include textbox and contol???
I have included
using system.text.
using system.collecti ons
using systemComment
-
hey...thanx ma.... spelling mstake he he... worst thing to do.....
got it now... thanx a lot....Comment
Comment