Take the 2-minute tour ×

I am developing my app in asp.net web forms. The textbox is set like this

<asp:TextBox ID="txt1" runat="server" Enabled="false" ></asp:TextBox>

and this is the corresponding HTML markup

<input name="txt1" type="text" value="1.0" id="txt1" disabled="disabled" />

It is not editable upto this point.

I enable Caret browsing in IE8 (press F7) and then this field becomes editable, though the text is grayed out and consequently gives a wrong feeling to the user that the field is editable. This does not happen if I mark the textbox as readonly, but I do not want to mark it as a readonly field. Any suggestions on how to have the textbox in disabled mode when in Caret Browsing.

Edit1: I am not looking for a solution which would change IE settings/registry, am looking for a programmatic solution as my site is a public facing website

Edit2: View states are enabled for the page and for the controls

share|improve this question
Why do you not want to use readonly if that solves the problem? –  adam0101 Mar 2 '10 at 20:59
we have some existing code, changing it to readonly would mean that we would have to change it in other places too –  ram Mar 2 '10 at 21:16
I don't see what affect setting an already disabled textbox to readonly would have that you would need to make other changes. –  adam0101 Mar 2 '10 at 21:45
I know this is an old post, but thanks for reporting this, I was going crazy trying to figure out how one of the customers was able to do that. Here is the jQuery snippet I used to fix this if ($.browser.msie) {$('input[disabled=disabled]').attr('readonly', 'readonly');} –  Dan Manastireanu Jan 19 '11 at 12:57

2 Answers 2

I can get you started quickly with this script:

<script> document.onkeyup = KeyCheck; 

function KeyCheck() {   alert(document.getElementById("txt1").value); }  </script> </script>

Put this all the way on top of the html. Now you get hold of the keypress. When in caret mode, IE seems to ignore the text's javascript events

share|improve this answer
Is this a solution ?you are just showing the textbox value on the onkeyup event. How does it prevent me from altering the textbox value ? –  ram Mar 2 '10 at 19:25
See my second answer. I had given you a hint for handling this scenario in first answer. Thanks for the -ve marking! –  ring bearer Mar 3 '10 at 14:49

Alright. I gave you a Hint to build up on. (Thanks for the -1) Here is the HTML code that you are looking for. Make sure to populate the initialVal using ASP code.

document.onkeyup = KeyCheck;       
var initialVal="1.0"

function KeyCheck()
    if(document.getElementById("txt1").value != initialVal) {
        document.getElementById("txt1").value = initialVal;
        return false;

share|improve this answer

Your Answer


