今天忽然遇到一个棘手的问题,用户通过Web系统录入数据时本应该是使用全角输入法的,但用户在录入时一部分使用了半角,导致系统出现问题(至于问题的细节就不讲了),网上游了半天,找到很多方法,因为是使用的是asp.net,所以就存在一个服务器控件和客户端控件的问题.费话少说,先来看客户端的实现:
因为是文本框所以就有以下的解决方法:
<div style="BORDER-RIGHT: 1px dotted; BORDER-TOP: 1px dotted; Z-INDEX: 103; LEFT: 304px; BORDER-LEFT: 1px dotted; WIDTH: 304px; BORDER-BOTTOM: 1px dotted; POSITION: absolute; TOP: 306px; HEIGHT: 160px; BACKGROUND-COLOR: ghostwhite" ms_positioning="GridLayout"> <input id=act style="Z-INDEX: 101; LEFT: 24px; WIDTH: 96px; POSITION: absolute; TOP: 40px; HEIGHT: 22px" onclick="this.style.imeMode='active'" size=10 height="107692336"> <input id=inact style="Z-INDEX: 102; LEFT: 160px; WIDTH: 96px; POSITION: absolute; TOP: 40px; HEIGHT: 22px" onclick="this.style.imeMode='inactive'" size=10 name=Text1 height="36424328">
<div style="DISPLAY: inline; Z-INDEX: 103; LEFT: 24px; WIDTH: 70px; POSITION: absolute; TOP: 16px; HEIGHT: 15px" ms_positioning="FlowLayout">
<p>active</p>
</div>
<div style="DISPLAY: inline; Z-INDEX: 104; LEFT: 160px; WIDTH: 70px; POSITION: absolute; TOP: 16px; HEIGHT: 15px" ms_positioning="FlowLayout">
<p>inactive</p>
</div>
<input id=auto1 style="Z-INDEX: 105; LEFT: 24px; WIDTH: 96px; POSITION: absolute; TOP: 112px; HEIGHT: 22px" onclick="this.style.imeMode='auto'" size=10 name=Text1 height="107692720"> <input id=disab1 style="Z-INDEX: 106; LEFT: 160px; WIDTH: 96px; POSITION: absolute; TOP: 112px; HEIGHT: 22px" onclick="this.style.imeMode='disabled'" size=10 name=Text2 height="36425352">
<div style="DISPLAY: inline; Z-INDEX: 107; LEFT: 24px; WIDTH: 70px; POSITION: absolute; TOP: 88px; HEIGHT: 15px" ms_positioning="FlowLayout">
<p>auto</p>
</div>
<div style="DISPLAY: inline; Z-INDEX: 108; LEFT: 160px; WIDTH: 70px; POSITION: absolute; TOP: 88px; HEIGHT: 15px" ms_positioning="FlowLayout">
<p>disable</p>
</div>
active
inactive
auto
disable
再说说服务器的实现,本想通过jscript脚本直接实现的,不过后在利用document.getElementById取元素时总是出现错误提示:元素不存在或不能为空.
最后没办法只能用老办法在服务器实现:
TextBox.Attributes.Add("onclick","this.style.imgMode='disabled'");
庆幸的是最后解决的问题.