Click here to Skip to main content
15,900,725 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Open a server side document using a client's program Pin
markymark8222-Feb-07 1:37
markymark8222-Feb-07 1:37 
AnswerRe: Open a server side document using a client's program Pin
badgrs22-Feb-07 1:45
badgrs22-Feb-07 1:45 
AnswerRe: Open a server side document using a client's program Pin
Paddy Boyd22-Feb-07 1:41
Paddy Boyd22-Feb-07 1:41 
GeneralRe: Open a server side document using a client's program Pin
markymark8222-Feb-07 3:32
markymark8222-Feb-07 3:32 
GeneralRe: Open a server side document using a client's program Pin
Paddy Boyd22-Feb-07 3:35
Paddy Boyd22-Feb-07 3:35 
GeneralRe: Open a server side document using a client's program Pin
markymark8222-Feb-07 3:39
markymark8222-Feb-07 3:39 
GeneralRe: Open a server side document using a client's program Pin
markymark8222-Feb-07 4:20
markymark8222-Feb-07 4:20 
QuestionDisable all textboxes in a page. Pin
MY120121-Feb-07 23:39
MY120121-Feb-07 23:39 
Hello.

I have a problem - and it's probably me not understanding the concept - but I want to programatically disable all controls in my aspx page - if the user watching the page is not authorized to edit the content.

Now this should be an easy task, so I've tried a couple of methods like looping through the page's Controls property and have all textboxes set their Enabled property to false. The following code does not work. I'm using a MasterPage, but I can't think of anything, that makes this a problem.

When I "ask" the MasterPage to print out the "count" for it's controls property it says there is about 5 items in the list. Although the page contains around 10 TextBoxes!

So what am I misunderstanding here?

Anyway here's the code:

 foreach (Control c in Page.Controls)
 {
     switch (c.GetType().ToString())
     {
         case "System.Web.UI.WebControls.TextBox":
             ((TextBox)c).Enabled = false;
             break;
         case "System.Web.UI.WebControls.DropDownList":
             ((DropDownList)c).Enabled = false;
             break;
         case "System.Web.UI.WebControls.ImageButton":
             ((ImageButton)c).Enabled = false;
             break;
         default:
             break;
     }
}


I hope someone can help!

Thanks in advance.

Best Regards
Soeren
AnswerRe: Disable all textboxes in a page. Pin
Michael Sync21-Feb-07 23:48
Michael Sync21-Feb-07 23:48 
AnswerRe: Disable all textboxes in a page. Pin
Harini N K22-Feb-07 0:00
Harini N K22-Feb-07 0:00 
AnswerRe: Disable all textboxes in a page. Pin
anufabian22-Feb-07 1:09
anufabian22-Feb-07 1:09 
GeneralRe: Disable all textboxes in a page. Pin
Sandeep Akhare22-Feb-07 1:18
Sandeep Akhare22-Feb-07 1:18 
AnswerRe: Disable all textboxes in a page. Pin
badgrs22-Feb-07 1:24
badgrs22-Feb-07 1:24 
GeneralRe: Disable all textboxes in a page. Pin
badgrs22-Feb-07 1:43
badgrs22-Feb-07 1:43 
QuestionHow to create a link to my table content Pin
jeya krishnan.v21-Feb-07 23:26
jeya krishnan.v21-Feb-07 23:26 
AnswerRe: How to create a link to my table content Pin
Tuwing.Sabado21-Feb-07 23:36
Tuwing.Sabado21-Feb-07 23:36 
AnswerRe: How to create a link to my table content Pin
Michael Sync21-Feb-07 23:40
Michael Sync21-Feb-07 23:40 
AnswerRe: How to create a link to my table content Pin
anufabian22-Feb-07 1:16
anufabian22-Feb-07 1:16 
QuestionCrystal Report Problem in asp.net/vb.net Pin
Kissy1621-Feb-07 23:15
Kissy1621-Feb-07 23:15 
AnswerRe: Crystal Report Problem in asp.net/vb.net Pin
Sylvester george21-Feb-07 23:37
Sylvester george21-Feb-07 23:37 
GeneralRe: Crystal Report Problem in asp.net/vb.net Pin
Kissy1621-Feb-07 23:50
Kissy1621-Feb-07 23:50 
QuestionCan Tooltip be used inside a Datagrid Pin
kiran0121-Feb-07 23:08
kiran0121-Feb-07 23:08 
AnswerRe: Can Tooltip be used inside a Datagrid Pin
anufabian22-Feb-07 19:30
anufabian22-Feb-07 19:30 
QuestionSynchronizing Gridview and Formview Pin
me.name21-Feb-07 23:09
me.name21-Feb-07 23:09 
QuestionGridview + asp.net 2.0 + c# Pin
ritu432121-Feb-07 22:58
ritu432121-Feb-07 22:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.