Making Fields read-only
-
On my web form I have a dropdown list. What I want is when I select "Closed" in the drop down list then the rest of the fields on the web form will be rendered Read-only as the form is not to be edited after it has been "Closed". Anyone any ideas how to do this. macca
-
On my web form I have a dropdown list. What I want is when I select "Closed" in the drop down list then the rest of the fields on the web form will be rendered Read-only as the form is not to be edited after it has been "Closed". Anyone any ideas how to do this. macca
Hi macca: In the onChange event of dropdown, you need to have a clientside JavaScript which should check the value. If it is closed then, you can get all textBoxes via document.getElementsByTagName("input") and if it is text, then you can set readOnly = true. readOnly may not be supported by other type of controls which support only disabled. Also, check out the compatibility against Netscape/FireFox. Deepak Kumar Vasudevan Personal Web: http://vdeepakkumar.netfirms.com/ I Blog At: http://deepak.blogdrive.com/
-
Hi macca: In the onChange event of dropdown, you need to have a clientside JavaScript which should check the value. If it is closed then, you can get all textBoxes via document.getElementsByTagName("input") and if it is text, then you can set readOnly = true. readOnly may not be supported by other type of controls which support only disabled. Also, check out the compatibility against Netscape/FireFox. Deepak Kumar Vasudevan Personal Web: http://vdeepakkumar.netfirms.com/ I Blog At: http://deepak.blogdrive.com/
-
On my web form I have a dropdown list. What I want is when I select "Closed" in the drop down list then the rest of the fields on the web form will be rendered Read-only as the form is not to be edited after it has been "Closed". Anyone any ideas how to do this. macca
In addition to what the gentleman who replied first suggested, you could alternatively use the SelectedIndexChanged event of the dropdown and write server-side code that disables the controls (control.Enabled = false;). Falcon.
-
On my web form I have a dropdown list. What I want is when I select "Closed" in the drop down list then the rest of the fields on the web form will be rendered Read-only as the form is not to be edited after it has been "Closed". Anyone any ideas how to do this. macca
It depends on how your dropdown list is working. If you are causing a postback each time, then set each field to read only on the server side. eg TextBox1.ReadOnly = true; if your dropdown list does not post back, you will have to implement this in javascript.
-
It depends on how your dropdown list is working. If you are causing a postback each time, then set each field to read only on the server side. eg TextBox1.ReadOnly = true; if your dropdown list does not post back, you will have to implement this in javascript.
-
Thanks for the replies guys. Toticow how do you set the dropdown list to Post Back. In the PageLoad I have my page set to: If Not Page.IsPostBack Then page info...... Do I have to change the page.ispostback or can I do it another way? macca
Ok, firstly ensure the dropdownlist is set to autopostback (In the designer, set this to true). In the PageLoad Event, do something like IF(IsPostBack) { if (DropDownList.value = "nothing")//Basically check for the word you want to search { textBox1.readonly = true; } }
-
Ok, firstly ensure the dropdownlist is set to autopostback (In the designer, set this to true). In the PageLoad Event, do something like IF(IsPostBack) { if (DropDownList.value = "nothing")//Basically check for the word you want to search { textBox1.readonly = true; } }