开发者

Disabling an ASP.net textbox without actually disabling it?

Within an ASP.Net application I have, there is a textbox that gets a date f开发者_如何学Pythonrom 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?


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


Try this

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

this worked for me.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜