2011年9月17日土曜日

ASP.NETサーバ・コントロール上のIMEモードを制御する方法

※この設定はIE 5.x以降のみ有効となります。IE7.0でも有効性は確認済み

ここでは、active/disabledという2つのCSSクラスを定義しているが、それぞれのクラスで指定されているのがime-modeプロパティだ。IE 5.x以降のCSSでは、ime-modeプロパティを用いることで、該当するフォーム要素にフォーカスが当たったタイミングで、有効なIMEモードを制御できる。以下に、ime-modeプロパティで指定可能な設定値を一覧表にまとめておく。

値 概要
auto 自動(デフォルト)。モード変更可能
active 日本語入力モード。モード変更可能
inactive 英数字入力モード。モード変更可能
disabled 英数字入力モード。モード変更不可
 
ime-modeプロパティで指定可能な値

 次の画面は、IMEモードを自動的に切り替えるサンプル・プログラムを実際に実行したところである。

 

Sample 青字の部分が変更点になる。


<%@ Page ContentType="text/html" %>
<html>
<head>
<title>IMEサンプル</title>
<style type="text/css">
<!--
.active {ime-mode: active;}
.disabled {ime-mode: disabled;}
-->
</style>
</head>
<body>
<form runat="Server">
<table border="0">
<tr>
  <th align="right">氏名:</th>
  <td><asp:TextBox id="name" runat="Server" size="20" CssClass="active" /></td>
</tr><tr>
  <th align="right">E-Mail:</th>
  <td><asp:TextBox id="email" runat="Server" size="30" CssClass="disabled" /></td>
</tr><tr>
  <th align="right">住所:</th>
  <td><asp:TextBox id="address" runat="Server" size="50" CssClass="active" /></td>
</tr><tr>
  <td rowspan="2"><asp:Button id="sbm" runat="Server" Text="送信" /></td>
</tr>
</table>
</form>
</body>
</html>

 


ASP.NET VB2005 IME 制御

 

0 件のコメント:

コメントを投稿