<asp:TextBox ID="TextBox3" runat="server" ReadOnly="True" ></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender2" TargetControlID="TextBox3"
runat="server"> I have use text box and calender
<asp:TextBox ID="TextBox3" runat="server" ReadOnly="True" ></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender2" TargetControlID="TextBox3"
runat="server"> I have use text box and calender
Short answer: an HTML input with readonly will be submitted with the form; a disabled input (Enabled="False") will not. So setting Enabled="False" (as suggested) makes the problem worse. If a readonly textbox value is not reaching the database, something else is dropping or overwriting the value.
Quick troubleshooting checklist:
Two common fixes that are safe and reliable:
Example pattern (client-side enable-before-submit):
<script type="text/javascript">
function enableForSubmit(clientId) {
var el = document.getElementById(clientId);
if (el) el.readOnly = false;
return true;
}
</script>
<asp:Button ID="btnSave" runat="server" Text="Save"
OnClientClick="return enableForSubmit('<%= TextBox3.ClientID %>');" /> Alternative: copy to a HiddenField in an OnClientClick and insert ServerSide from the HiddenField. As hinted, toggling ReadOnly client-side is a valid approach; just avoid Enabled="False" if the value must be posted.
Jump to Post— bhartman21 2Instead of using the ReadOnly="True" property ... how about using the Enabled="False" property?
Instead of using the ReadOnly="True" property ... how about using the Enabled="False" property?
Another option would be to fire a javascript to set the ReadOnly property to "False" after the validation of the form, but before actually submitting the form.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.