Textbox becomes readonly on postback even when setting the readonly attribute to false manually

So, in my current application in ASP.net, I have a weird bug. Textbox that I have added in the existing page, goes in read only mode after the postback. When the page loads the first time, textbox works fine. But after page load, it stays enabled and in read only mode.

I checked Dev tools in IE, and the text box has readonly attribute set to false, as expected. I can even set the other properties from the js function called during page load, and they work fine. Only the readonly attribute doesn't work.

I am unable to figure out a reason as to why this is happening, so I am unable to solve it either.

 <tr>  <td nowrap align="right"> <asp:Label ID="lblResTimeDescription" runat="server" EnableViewState="False" CssClass="Common">Response Time Comments</asp:Label>&nbsp;:&nbsp;</td>

Textbox code:

>  <asp:TextBox ID="txtResTimeDescription" CssClass="TextBox"
> MaxLength="200" TextMode="MultiLine" runat="server" Width="100%"
> Height="50px" ReadOnly="false"></asp:TextBox>

P.S. Do let me know, which code I can post here.

Edit: JS function called at the very end of the page load.

function fnEnableComments(e) {
var strCompletion = document.getElementById("ddlCompletion").value;
if (strCompletion == "Y") {
    document.getElementById("txtResTimeDescription").disabled = false;
    document.getElementById("txtResTimeDescription").setAttribute("value", "zyx");
else {
    document.getElementById("txtResTimeDescription").disabled = true;
    document.getElementById("txtResTimeDescription").value = "";


This function gets called properly, as I can see the value change to zyx.

Edit 2:

Removed all hints of readonly from code and js. Still the same problem. Also, the textbox is getting enabled properly, on change of dropdown, gets the value set properly. I can even click on the text box to set the focus, but I just can't change the value in it.

Edit 3:

Program workflow explanation: User select a record from the listings page and the page loads with information about that record. User can enter data, and save the same. But user can't set the completion flag to yes, without providing comments. In other cases, the comment is not needed at all. This textbox is used to add comments. Typically user updates all the data, and saves the information. After saving the information, page refreshes, and at which point user changes the completion flag. So, on dropdown change and on page load, I check for the completion flag and enable and disable the comments textbox.

This all works fine as far as logic goes. Only thing is when users saves the data first time, and page reloads, textbox stays readonly even when user changes the completion flag. If user refreshes the page again, then code works fine. Basically, this bug causes user to refresh the page, manually after every save, defeating the purpose of refreshing from the code.


attempts to place this before finalizing what you need the first time in the code behind


with this if you put readonly attribute when you take away this textbox

Finally found a solution. I still don't know why it is happening. But below code did the trick.

        document.getElementById("txtResTimeDescription").setAttribute("readOnly", false);

I was using the same code earlier too, sadly with wrong capitalization of the attribute.


 ? How to remove multiple dynamically generated elements at the same time by their class name?
 ? set readonly property to false for an html text input on clicking on Edit
 ? How to keep readonly="false" for input boxes with same class when moving focus between them?
 ? Does std::vector behave different for clearing or deleting PODs
 ? Does std::vector behave different for clearing or deleting PODs
 ? Does std::vector behave different for clearing or deleting PODs
 ? Why is there not an std::is_struct type trait?
 ? Is std::vector::size() allowed to require non-trivial computations? When would it make sense?
 ? state of std::vector after std::bad_alloc
 ? std::vector - how to free the memory of char* elements in a vector?