編程,大家都希望越簡單越好,我也不例外。比如要輸入日期時,我會選擇簡單的CalendarTextBox 。
理由很簡單,總所周知判斷日期很麻煩,要考慮各種因素,但是使用CalendarTextBox 就使的一切都簡單化了,省去的大量判斷程式。
但隨之又出現了新的問題,CalendarTextBox 沒有readOnly屬性,因為一選,整個CalendarTextBox 就不可用了。就沒有辦法了嗎?當然不是。
因為下面就有解決的方法:
1.加入綫面代碼
AutoPostBack="false" ShowImage="False" onpaste="return false;" onkeypress="event.keyCode=0;event.returnValue=false;" onkeydown="this.select();" onclick="this.select();" style="ime-mode: disabled;"
2.使用正則表達式
http://topic.youkuaiyun.com/t/20030928/15/2311107.html