3

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?

2
  • What does enabled = true and readonly=true yield? Commented 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 extender Commented Aug 22, 2011 at 1:49

4 Answers 4

14

I figured it out, simply enter onkeypress="return false;" within the HTML tag

Sign up to request clarification or add additional context in comments.

Comments

5

Try this

<asp:textbox id="txt1" onfocus="blur()" runat="server"/>

this worked for me.

Comments

1

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

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.