|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| ||||||||||||||||||||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Disable all form fields
Hello,
I have this huge form, and when i preview it, i want to disable all fields, so they are read only. i can do it one by one but it'll take a loong time. is it possible to somehow loop through the form or through a table and disable everything all at once? Thanks in advance! any help would be much appreciated ------------- sorry, i found it, turns out its much easier then i expected http://steveorr.net/faq/controltreerecursion.aspx |
|
#2
|
||||
|
||||
|
The easiest way is to just put all the controls into a panel, then you can set "enabled="false" and it will disable everything inside it.
Code:
<asp:Panel ID="Panel1" runat="server" enabled="false">
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</asp:Panel>
Last edited by Rictor : October 28th, 2009 at 05:19 PM. |
|
#3
|
|||
|
|||
|
everything works perfect in chrome and Mozilla, but in IE, the labels are also set an disabled (not only the fillable fields), which makes the form really hard to read.
is there a fix or another way around it? Thanks! can i maybe set "everything except for labels" to dislabled. |
|
#4
|
||||
|
||||
|
Not with the way I showed you to do it, that is the easiest way but it also gives you the least control. With the link you posted in your original, that way would give you the ability to check if it's a label, if so do nothing, else disable the control. Basically teh same theory he uses, but instead of looking for textboxes to color differently, you look for labels to ignore, but disable everything else.
![]() |
![]() |
| Viewing: ASP Free Forums > Programming > .NET Development > Disable all form fields |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|