サーバー側でのフォーカス移動処理が動作しない場合がある
対象製品
InputMan for ASP.NET 8.0J
状況
修正済み
詳細
サーバー側でPage.SetFocusメソッドや、InputManコントロールのFocusメソッドを実行しても、ページの読み込み後、指定されたコントロールへフォーカスが移動しません。
Internet Explorer 8を使用している場合は、すべてのInputManコントロールでこの現象が発生します。
また、Internet Explorer 8以外のブラウザでは、以下のコントロールで同様の現象が発生します。
カレンダーコントロール
リストコントロール
Internet Explorer 8を使用している場合は、すべてのInputManコントロールでこの現象が発生します。
また、Internet Explorer 8以外のブラウザでは、以下のコントロールで同様の現象が発生します。
回避方法
この問題はService Pack 1(v8.0.2015.929)で修正されました。
不具合を修正した最新のサービスパックは、アップデートページからダウンロードできます。
なお、この問題の修正により以下の不具合が確認されています。
[39133]マスターページ使用時にコンテンツページのサーバー側でフォーカス移動をするとスクリプトエラーが発生する
Service Pack 1より前のバージョンでは次の方法で回避可能です。
以下の回避コードを追加します。
[Visual Basic]
Imports System.Reflection
Partial Class _Default
Inherits System.Web.UI.Page
Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
MyBase.OnPreRender(e)
Me.RegisterFocusScript()
End Sub
Private Sub RegisterFocusScript()
Dim t As Type = Me.Page.GetType()
Dim pi As PropertyInfo = t.GetProperty("FocusedControl", BindingFlags.Instance Or BindingFlags.NonPublic)
Dim focusedControl As Control = CType(pi.GetValue(Me, Nothing), Control)
If IsNothing(focusedControl) Then
pi = t.GetProperty("FocusedControlID", BindingFlags.Instance Or BindingFlags.NonPublic)
Dim focusedControlID As String = CType(pi.GetValue(Me, Nothing), String)
If focusedControlID <> String.Empty Then
focusedControl = Me.FindControl(focusedControlID)
End If
End If
If Not IsNothing(focusedControl) Then
If TypeOf (focusedControl) Is GrapeCity.Web.Input.Core.BaseControl Or TypeOf (focusedControl) Is GrapeCity.Web.Input.Core.BaseModelContainerControl Then
Dim script As String = "setTimeout(function(){ FindIMControl('" + focusedControl.ClientID + "').SetFocus(); } , 100);"
Dim sb As StringBuilder = New StringBuilder()
sb.AppendFormat("GCIM.Utility.AddDocumentLoadTask(function(){{")
sb.AppendLine()
sb.AppendFormat("{0}", script)
sb.AppendFormat("}}, {0});", 10)
sb.AppendLine()
ClientScript.RegisterStartupScript(GetType(Page), "FocusScript", sb.ToString(), True)
End If
End If
End Sub
End Class
[C#]
using System.Reflection;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
this.RegisterFocusScript();
}
private void RegisterFocusScript()
{
Type t = this.Page.GetType();
PropertyInfo pi = t.GetProperty("FocusedControl", BindingFlags.Instance | BindingFlags.NonPublic);
Control focusedControl = (Control)pi.GetValue(this, null);
if (focusedControl == null)
{
pi = t.GetProperty("FocusedControlID", BindingFlags.Instance | BindingFlags.NonPublic);
string focusedControlID = (string)pi.GetValue(this, null);
if (focusedControlID != "")
{
focusedControl = this.FindControl(focusedControlID);
}
}
if (focusedControl != null)
{
if (focusedControl is GrapeCity.Web.Input.Core.BaseControl || focusedControl is GrapeCity.Web.Input.Core.BaseModelContainerControl)
{
string script = "setTimeout(function(){ ¥r¥nFindIMControl(¥"" + focusedControl.ClientID + "¥").SetFocus();}, 100);";
StringBuilder sb = new StringBuilder();
sb.AppendFormat("GCIM.Utility.AddDocumentLoadTask(function(){{");
sb.AppendLine();
sb.AppendFormat("{0}", script);
sb.AppendFormat("}}, {0});", 10);
sb.AppendLine();
ClientScript.RegisterStartupScript(typeof(Page), "FocusScript", sb.ToString(), true);
}
}
}
}
不具合を修正した最新のサービスパックは、アップデートページからダウンロードできます。
なお、この問題の修正により以下の不具合が確認されています。
[39133]マスターページ使用時にコンテンツページのサーバー側でフォーカス移動をするとスクリプトエラーが発生する
Service Pack 1より前のバージョンでは次の方法で回避可能です。
以下の回避コードを追加します。
[Visual Basic]
Imports System.Reflection
Partial Class _Default
Inherits System.Web.UI.Page
Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
MyBase.OnPreRender(e)
Me.RegisterFocusScript()
End Sub
Private Sub RegisterFocusScript()
Dim t As Type = Me.Page.GetType()
Dim pi As PropertyInfo = t.GetProperty("FocusedControl", BindingFlags.Instance Or BindingFlags.NonPublic)
Dim focusedControl As Control = CType(pi.GetValue(Me, Nothing), Control)
If IsNothing(focusedControl) Then
pi = t.GetProperty("FocusedControlID", BindingFlags.Instance Or BindingFlags.NonPublic)
Dim focusedControlID As String = CType(pi.GetValue(Me, Nothing), String)
If focusedControlID <> String.Empty Then
focusedControl = Me.FindControl(focusedControlID)
End If
End If
If Not IsNothing(focusedControl) Then
If TypeOf (focusedControl) Is GrapeCity.Web.Input.Core.BaseControl Or TypeOf (focusedControl) Is GrapeCity.Web.Input.Core.BaseModelContainerControl Then
Dim script As String = "setTimeout(function(){ FindIMControl('" + focusedControl.ClientID + "').SetFocus(); } , 100);"
Dim sb As StringBuilder = New StringBuilder()
sb.AppendFormat("GCIM.Utility.AddDocumentLoadTask(function(){{")
sb.AppendLine()
sb.AppendFormat("{0}", script)
sb.AppendFormat("}}, {0});", 10)
sb.AppendLine()
ClientScript.RegisterStartupScript(GetType(Page), "FocusScript", sb.ToString(), True)
End If
End If
End Sub
End Class
[C#]
using System.Reflection;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
this.RegisterFocusScript();
}
private void RegisterFocusScript()
{
Type t = this.Page.GetType();
PropertyInfo pi = t.GetProperty("FocusedControl", BindingFlags.Instance | BindingFlags.NonPublic);
Control focusedControl = (Control)pi.GetValue(this, null);
if (focusedControl == null)
{
pi = t.GetProperty("FocusedControlID", BindingFlags.Instance | BindingFlags.NonPublic);
string focusedControlID = (string)pi.GetValue(this, null);
if (focusedControlID != "")
{
focusedControl = this.FindControl(focusedControlID);
}
}
if (focusedControl != null)
{
if (focusedControl is GrapeCity.Web.Input.Core.BaseControl || focusedControl is GrapeCity.Web.Input.Core.BaseModelContainerControl)
{
string script = "setTimeout(function(){ ¥r¥nFindIMControl(¥"" + focusedControl.ClientID + "¥").SetFocus();}, 100);";
StringBuilder sb = new StringBuilder();
sb.AppendFormat("GCIM.Utility.AddDocumentLoadTask(function(){{");
sb.AppendLine();
sb.AppendFormat("{0}", script);
sb.AppendFormat("}}, {0});", 10);
sb.AppendLine();
ClientScript.RegisterStartupScript(typeof(Page), "FocusScript", sb.ToString(), true);
}
}
}
}