Within an ASP.Net application I have, there is a textbox that gets a date from a CalendarExtender. When the textbox is populated it checks that date with another date on the form and displays a modalpopupextender popup if the dates are wrong. However, I DO NOT want to allow user input into this textbox, so when I set the ReadOnly field to false and tried Enabled to false, it doesn't allow manual entry however it ALSO disabled the postback and will not call the TextChanged event to fire the modalpopupextender.
So is there a way to disable manual entry and not set it to ReadOnly?
-
What does enabled = true and readonly=true yield?Adam Tuliper– Adam Tuliper2011-08-22 01:10:55 +00:00Commented Aug 22, 2011 at 1:10
-
enabled = true and readonly accomplish kinda the same thing, the both prohibit the user from entering anything into the field. That is what I want but doing so will disable the modalpopup extendermattgcon– mattgcon2011-08-22 01:49:10 +00:00Commented Aug 22, 2011 at 1:49
4 Answers
Add the below properties in the tag of textbox
onkeydown="return false" onpaste="return false"
ex:
<asp:TextBox ID="TillDate_TextBox" runat="server" onkeydown="return false" onpaste="return false"></asp:TextBox>
the first property block typing in textbox and the second property block pasting in it
Comments
I'm not familiar with the exact components you are using, however the usual way to accomplish things like this is the following. Have selecting the date on the calendar modify the value of a hidden form field. This will restrict the user from editing the value directly. Then create another element like a div or a span, and use javascript to update the span/div to the value selected on the calendar.