チェンジセット 1624 (default)


以下の違いを無視:
日時:
2023/10/27 18:41:28 (11ヵ月前)
更新者:
hizuya@…
ログメッセージ:
  • RadioButtonList が非同期ポストバックに登録されている場合、クライアント側でレンダリング時に選択されていたラジオボタンをクリックしたときにポストバックが発生しない問題に対応。
場所:
framework/trunk
ファイル:
6個の更新

凡例:

未変更
追加
削除
  • framework/trunk/WebApplication/UI/UpdatePanelPage.aspx

    r1619 r1624  
    6767            </div> 
    6868 
     69            <h2>RadioButtonList</h2> 
     70 
     71            <h3>UpdatePanel {RadioButtonList(AutoPostBack="True"), PlaceHolder}</h3> 
     72            <div> 
     73                <sff:UpdatePanel ID="UpdatePanel201" runat="server"> 
     74                    <ContentTemplate> 
     75                        <asp:RadioButtonList ID="RadioButtonList201" runat="server" 
     76                            AutoPostBack="True" 
     77                            OnSelectedIndexChanged="RadioButtonList201_OnSelectedIndexChanged"> 
     78                            <Items> 
     79                                <asp:ListItem Value="A" Selected="True"/> 
     80                                <asp:ListItem Value="B"/> 
     81                                <asp:ListItem Value="C"/> 
     82                            </Items> 
     83                        </asp:RadioButtonList> 
     84                        <div> 
     85                            <asp:Label runat="server" ID="Label201"/> 
     86                        </div> 
     87                    </ContentTemplate> 
     88                </sff:UpdatePanel> 
     89            </div> 
     90 
     91            <h3>sff:RadioButtonList(AutoPostBack="True"), UpdatePanel {PlaceHolder}</h3> 
     92            <div> 
     93                <%-- 選択済のラジオボタンを再度選択した場合に非同期ポストバックが実行されない問題の対応 --%> 
     94                <sff:RadioButtonList ID="RadioButtonList202" runat="server" 
     95                    AutoPostBack="True" 
     96                    OnSelectedIndexChanged="RadioButtonList202_OnSelectedIndexChanged"> 
     97                    <Items> 
     98                        <asp:ListItem Value="A"/> 
     99                        <asp:ListItem Value="B" Selected="True"/> 
     100                        <asp:ListItem Value="C"/> 
     101                    </Items> 
     102                </sff:RadioButtonList> 
     103                <sff:UpdatePanel ID="UpdatePanel202" runat="server"> 
     104                    <ContentTemplate> 
     105                        <div> 
     106                            <asp:Label runat="server" ID="Label202"/> 
     107                        </div> 
     108                    </ContentTemplate> 
     109                    <Triggers> 
     110                        <asp:AsyncPostBackTrigger ControlID="RadioButtonList202"/> 
     111                    </Triggers> 
     112                </sff:UpdatePanel> 
     113            </div> 
     114 
     115            <h3>sff:RadioButtonList(AutoPostBack="True", Enabled="False"), UpdatePanel {PlaceHolder}</h3> 
     116            <div> 
     117                <%-- 選択済のラジオボタンを再度選択した場合に非同期ポストバックが実行されない問題の対応 --%> 
     118                <sff:RadioButtonList ID="RadioButtonList203" runat="server" 
     119                    AutoPostBack="True" 
     120                    Enabled="False" 
     121                    OnSelectedIndexChanged="RadioButtonList203_OnSelectedIndexChanged"> 
     122                    <Items> 
     123                        <asp:ListItem Value="A"/> 
     124                        <asp:ListItem Value="B"/> 
     125                        <asp:ListItem Value="C" Selected="True"/> 
     126                    </Items> 
     127                </sff:RadioButtonList> 
     128                <sff:UpdatePanel ID="UpdatePanel203" runat="server"> 
     129                    <ContentTemplate> 
     130                        <div> 
     131                            <asp:Label runat="server" ID="Label203"/> 
     132                        </div> 
     133                    </ContentTemplate> 
     134                    <Triggers> 
     135                        <asp:AsyncPostBackTrigger ControlID="RadioButtonList203"/> 
     136                    </Triggers> 
     137                </sff:UpdatePanel> 
     138            </div> 
     139 
    69140        </div> 
    70141    </form> 
     
    72143</html> 
    73144 
     145 
     146 
  • framework/trunk/WebApplication/UI/UpdatePanelPage.aspx.cs

    r1619 r1624  
    5757                PlaceHolder101.Visible = CheckBox101.Checked; 
    5858                PlaceHolder102.Visible = CheckBox102.Checked; 
     59                Label201.Text = RadioButtonList201.SelectedValue; 
     60                Label202.Text = RadioButtonList202.SelectedValue; 
     61                Label203.Text = RadioButtonList203.SelectedValue; 
    5962            } 
    6063 
     
    9598            PlaceHolder102.Visible = CheckBox102.Checked; 
    9699        } 
     100 
     101        /// <summary> 
     102        /// <see cref="RadioButtonList201"/> の選択状態が変更されたときに呼び出されるイベントハンドラです。 
     103        /// </summary> 
     104        /// <param name="sender"> 
     105        /// イベントの発生元。 
     106        /// </param> 
     107        /// <param name="e"> 
     108        /// イベント情報。 
     109        /// </param> 
     110        protected void RadioButtonList201_OnSelectedIndexChanged(object sender, EventArgs e) 
     111        { 
     112            Label201.Text = RadioButtonList201.SelectedValue; 
     113        } 
     114 
     115        /// <summary> 
     116        /// <see cref="RadioButtonList202"/> の選択状態が変更されたときに呼び出されるイベントハンドラです。 
     117        /// </summary> 
     118        /// <param name="sender"> 
     119        /// イベントの発生元。 
     120        /// </param> 
     121        /// <param name="e"> 
     122        /// イベント情報。 
     123        /// </param> 
     124        protected void RadioButtonList202_OnSelectedIndexChanged(object sender, EventArgs e) 
     125        { 
     126            Label202.Text = RadioButtonList202.SelectedValue; 
     127        } 
     128 
     129        /// <summary> 
     130        /// <see cref="RadioButtonList203"/> の選択状態が変更されたときに呼び出されるイベントハンドラです。 
     131        /// </summary> 
     132        /// <param name="sender"> 
     133        /// イベントの発生元。 
     134        /// </param> 
     135        /// <param name="e"> 
     136        /// イベント情報。 
     137        /// </param> 
     138        protected void RadioButtonList203_OnSelectedIndexChanged(object sender, EventArgs e) 
     139        { 
     140            Label203.Text = RadioButtonList203.SelectedValue; 
     141        } 
    97142    } 
    98143} 
  • framework/trunk/WebApplication/UI/UpdatePanelPage.aspx.designer.cs

    r1619 r1624  
    120120        /// </remarks> 
    121121        protected global::System.Web.UI.WebControls.TextBox TextBox102; 
     122         
     123        /// <summary> 
     124        /// UpdatePanel201 コントロール。 
     125        /// </summary> 
     126        /// <remarks> 
     127        /// 自動生成されたフィールド。 
     128        /// 変更するには、フィールドの宣言をデザイナー ファイルから分離コード ファイルに移動します。 
     129        /// </remarks> 
     130        protected global::FCSoft.SilverFrost.Framework.Web.UI.UpdatePanel UpdatePanel201; 
     131         
     132        /// <summary> 
     133        /// RadioButtonList201 コントロール。 
     134        /// </summary> 
     135        /// <remarks> 
     136        /// 自動生成されたフィールド。 
     137        /// 変更するには、フィールドの宣言をデザイナー ファイルから分離コード ファイルに移動します。 
     138        /// </remarks> 
     139        protected global::System.Web.UI.WebControls.RadioButtonList RadioButtonList201; 
     140         
     141        /// <summary> 
     142        /// Label201 コントロール。 
     143        /// </summary> 
     144        /// <remarks> 
     145        /// 自動生成されたフィールド。 
     146        /// 変更するには、フィールドの宣言をデザイナー ファイルから分離コード ファイルに移動します。 
     147        /// </remarks> 
     148        protected global::System.Web.UI.WebControls.Label Label201; 
     149         
     150        /// <summary> 
     151        /// RadioButtonList202 コントロール。 
     152        /// </summary> 
     153        /// <remarks> 
     154        /// 自動生成されたフィールド。 
     155        /// 変更するには、フィールドの宣言をデザイナー ファイルから分離コード ファイルに移動します。 
     156        /// </remarks> 
     157        protected global::FCSoft.SilverFrost.Framework.Web.UI.WebControls.RadioButtonList RadioButtonList202; 
     158         
     159        /// <summary> 
     160        /// UpdatePanel202 コントロール。 
     161        /// </summary> 
     162        /// <remarks> 
     163        /// 自動生成されたフィールド。 
     164        /// 変更するには、フィールドの宣言をデザイナー ファイルから分離コード ファイルに移動します。 
     165        /// </remarks> 
     166        protected global::FCSoft.SilverFrost.Framework.Web.UI.UpdatePanel UpdatePanel202; 
     167         
     168        /// <summary> 
     169        /// Label202 コントロール。 
     170        /// </summary> 
     171        /// <remarks> 
     172        /// 自動生成されたフィールド。 
     173        /// 変更するには、フィールドの宣言をデザイナー ファイルから分離コード ファイルに移動します。 
     174        /// </remarks> 
     175        protected global::System.Web.UI.WebControls.Label Label202; 
     176         
     177        /// <summary> 
     178        /// RadioButtonList203 コントロール。 
     179        /// </summary> 
     180        /// <remarks> 
     181        /// 自動生成されたフィールド。 
     182        /// 変更するには、フィールドの宣言をデザイナー ファイルから分離コード ファイルに移動します。 
     183        /// </remarks> 
     184        protected global::FCSoft.SilverFrost.Framework.Web.UI.WebControls.RadioButtonList RadioButtonList203; 
     185         
     186        /// <summary> 
     187        /// UpdatePanel203 コントロール。 
     188        /// </summary> 
     189        /// <remarks> 
     190        /// 自動生成されたフィールド。 
     191        /// 変更するには、フィールドの宣言をデザイナー ファイルから分離コード ファイルに移動します。 
     192        /// </remarks> 
     193        protected global::FCSoft.SilverFrost.Framework.Web.UI.UpdatePanel UpdatePanel203; 
     194         
     195        /// <summary> 
     196        /// Label203 コントロール。 
     197        /// </summary> 
     198        /// <remarks> 
     199        /// 自動生成されたフィールド。 
     200        /// 変更するには、フィールドの宣言をデザイナー ファイルから分離コード ファイルに移動します。 
     201        /// </remarks> 
     202        protected global::System.Web.UI.WebControls.Label Label203; 
    122203    } 
    123204} 
  • framework/trunk/WebLibrary/Sources/Reflections.cs

    r1622 r1624  
    2323{ 
    2424    using System; 
     25    using System.Collections.Generic; 
    2526    using System.Reflection; 
    2627 
     
    626627            } 
    627628        } 
     629 
     630 
     631        /// <summary> 
     632        /// <see cref="System.Web.UI.ScriptManager"/> に関係するリフレクションの集合です。 
     633        /// </summary> 
     634        internal static class ScriptManager 
     635        { 
     636            /// <summary> 
     637            /// <c>ScriptManager._pageRequestManager</c> フィールドの値を取得するデリゲートです。 
     638            /// </summary> 
     639            private static readonly Func<System.Web.UI.ScriptManager, object> GetPageRequestManagerDelegate; 
     640 
     641 
     642            /// <summary> 
     643            /// クラスを初期化します。 
     644            /// </summary> 
     645            static ScriptManager() 
     646            { 
     647                FieldInfo pageRequestManagerFieldInfo 
     648                    = typeof(System.Web.UI.ScriptManager).GetField( 
     649                        "_pageRequestManager", 
     650                        BindingFlags.Instance | BindingFlags.NonPublic); 
     651                if (pageRequestManagerFieldInfo != null) 
     652                { 
     653                    GetPageRequestManagerDelegate = delegate(System.Web.UI.ScriptManager scriptManager) 
     654                    { 
     655                        return pageRequestManagerFieldInfo.GetValue(scriptManager); 
     656                    }; 
     657                } 
     658            } 
     659 
     660 
     661            /// <summary> 
     662            /// 使用出来るかどうかを返します。 
     663            /// </summary> 
     664            /// <value> 
     665            /// 使用出来る場合は <see langword="true"/>。 
     666            /// それ以外の場合は <see langword="false"/>。 
     667            /// </value> 
     668            internal static bool IsValid 
     669            { 
     670                get 
     671                { 
     672                    return GetPageRequestManagerDelegate != null; 
     673                } 
     674            } 
     675 
     676 
     677            /// <summary> 
     678            /// <c>ScriptManager._pageRequestManager</c> フィールドの値を取得します。 
     679            /// </summary> 
     680            /// <param name="scriptManager"><see cref="System.Web.UI.ScriptManager"/>。</param> 
     681            /// <returns> 
     682            /// <c>ScriptManager._pageRequestManager</c> フィールドの値。 
     683            /// </returns> 
     684            internal static object GetPageRequestManager(System.Web.UI.ScriptManager scriptManager) 
     685            { 
     686                if (GetPageRequestManagerDelegate == null) 
     687                { 
     688                    return null; 
     689                } 
     690 
     691                return GetPageRequestManagerDelegate(scriptManager); 
     692            } 
     693        } 
     694 
     695 
     696        /// <summary> 
     697        /// <c>System.Web.UI.PageRequestManager</c> に関係するリフレクションの集合です。 
     698        /// </summary> 
     699        internal static class PageRequestManager 
     700        { 
     701            /// <summary> 
     702            /// <c>PageRequestManager._asyncPostBackControls</c> フィールドの値を取得するデリゲートです。 
     703            /// </summary> 
     704            private static readonly Func<object, List<System.Web.UI.Control>> GetAsyncPostBackControlsDelegate; 
     705 
     706 
     707            /// <summary> 
     708            /// クラスを初期化します。 
     709            /// </summary> 
     710            static PageRequestManager() 
     711            { 
     712                Type type = typeof(System.Web.UI.ScriptManager).Assembly.GetType("System.Web.UI.PageRequestManager", false); 
     713                if (type == null) 
     714                { 
     715                    return; 
     716                } 
     717 
     718                FieldInfo asyncPostBackControlsFieldInfo 
     719                    = type.GetField( 
     720                        "_asyncPostBackControls", 
     721                        BindingFlags.Instance | BindingFlags.NonPublic); 
     722                if (asyncPostBackControlsFieldInfo != null 
     723                    && asyncPostBackControlsFieldInfo.FieldType == typeof(List<System.Web.UI.Control>)) 
     724                { 
     725                    GetAsyncPostBackControlsDelegate = delegate(object obj) 
     726                    { 
     727                        return (List<System.Web.UI.Control>)asyncPostBackControlsFieldInfo.GetValue(obj); 
     728                    }; 
     729                } 
     730            } 
     731 
     732 
     733            /// <summary> 
     734            /// 使用出来るかどうかを返します。 
     735            /// </summary> 
     736            /// <value> 
     737            /// 使用出来る場合は <see langword="true"/>。 
     738            /// それ以外の場合は <see langword="false"/>。 
     739            /// </value> 
     740            internal static bool IsValid 
     741            { 
     742                get 
     743                { 
     744                    return GetAsyncPostBackControlsDelegate != null; 
     745                } 
     746            } 
     747 
     748 
     749            /// <summary> 
     750            /// <c>PageRequestManager._asyncPostBackControls</c> フィールドの値を取得します。 
     751            /// </summary> 
     752            /// <param name="pageRequestManager"><c>System.Web.UI.PageRequestManager</c>。</param> 
     753            /// <returns> 
     754            /// <c>PageRequestManager._asyncPostBackControls</c> フィールドの値。 
     755            /// </returns> 
     756            internal static List<System.Web.UI.Control> GetAsyncPostBackControls(object pageRequestManager) 
     757            { 
     758                if (GetAsyncPostBackControlsDelegate == null) 
     759                { 
     760                    return null; 
     761                } 
     762 
     763                return GetAsyncPostBackControlsDelegate(pageRequestManager); 
     764            } 
     765        } 
     766 
     767 
     768        /// <summary> 
     769        /// <see cref="System.Web.UI.WebControls.ListControl"/> に関係するリフレクションの集合です。 
     770        /// </summary> 
     771        internal static class ListControl 
     772        { 
     773            /// <summary> 
     774            /// <c>ListControl.SetControlToRepeatID</c> メソッドを呼び出すデリゲートです。 
     775            /// </summary> 
     776            private static readonly Action<System.Web.UI.Control, System.Web.UI.Control, int> SetControlToRepeatIdDelegate; 
     777 
     778 
     779            /// <summary> 
     780            /// クラスを初期化します。 
     781            /// </summary> 
     782            static ListControl() 
     783            { 
     784                MethodInfo setControlToRepeatIdMethodInfo 
     785                    = typeof(System.Web.UI.WebControls.ListControl).GetMethod( 
     786                        "SetControlToRepeatID", 
     787                        BindingFlags.Static | BindingFlags.NonPublic, 
     788                        null, 
     789                        new[] { typeof(System.Web.UI.Control), typeof(System.Web.UI.Control), typeof(int) }, 
     790                        null); 
     791                if (setControlToRepeatIdMethodInfo != null) 
     792                { 
     793                    SetControlToRepeatIdDelegate 
     794                        = (Action<System.Web.UI.Control, System.Web.UI.Control, int>)setControlToRepeatIdMethodInfo.CreateDelegate( 
     795                            typeof(Action<System.Web.UI.Control, System.Web.UI.Control, int>)); 
     796                } 
     797            } 
     798 
     799 
     800            /// <summary> 
     801            /// 使用出来るかどうかを返します。 
     802            /// </summary> 
     803            /// <value> 
     804            /// 使用出来る場合は <see langword="true"/>。 
     805            /// それ以外の場合は <see langword="false"/>。 
     806            /// </value> 
     807            internal static bool IsValid 
     808            { 
     809                get 
     810                { 
     811                    return SetControlToRepeatIdDelegate != null; 
     812                } 
     813            } 
     814 
     815 
     816            /// <summary> 
     817            /// <c>ListControl.SetControlToRepeatID</c> メソッドを呼び出します。 
     818            /// </summary> 
     819            /// <param name="owner">リピートするコントロールのオーナー。</param> 
     820            /// <param name="controlToRepeat">リピートするコントロール。</param> 
     821            /// <param name="index">インデックス。</param> 
     822            internal static void SetControlToRepeatId( 
     823                System.Web.UI.Control owner, 
     824                System.Web.UI.Control controlToRepeat, 
     825                int index) 
     826            { 
     827                if (SetControlToRepeatIdDelegate == null) 
     828                { 
     829                    return; 
     830                } 
     831 
     832                SetControlToRepeatIdDelegate(owner, controlToRepeat, index); 
     833            } 
     834        } 
     835 
     836 
     837        /// <summary> 
     838        /// <see cref="System.Web.UI.WebControls.RadioButtonList"/> に関係するリフレクションの集合です。 
     839        /// </summary> 
     840        internal static class RadioButtonList 
     841        { 
     842            /// <summary> 
     843            /// <c>RadioButtonList.ControlToRepeat</c> プロパティの値を取得するデリゲートです。 
     844            /// </summary> 
     845            private static readonly Func<System.Web.UI.WebControls.RadioButtonList, System.Web.UI.WebControls.RadioButton> GetControlToRepeatDelegate; 
     846 
     847 
     848            /// <summary> 
     849            /// クラスを初期化します。 
     850            /// </summary> 
     851            static RadioButtonList() 
     852            { 
     853                PropertyInfo controlToRepeatPropertyInfo 
     854                    = typeof(System.Web.UI.WebControls.RadioButtonList).GetProperty( 
     855                        "ControlToRepeat", 
     856                        BindingFlags.Instance | BindingFlags.NonPublic, 
     857                        null, 
     858                        typeof(System.Web.UI.WebControls.RadioButton), 
     859                        Type.EmptyTypes, 
     860                        null); 
     861                if (controlToRepeatPropertyInfo != null && controlToRepeatPropertyInfo.CanRead) 
     862                { 
     863                    GetControlToRepeatDelegate = delegate(System.Web.UI.WebControls.RadioButtonList radioButtonList) 
     864                    { 
     865                        return (System.Web.UI.WebControls.RadioButton)controlToRepeatPropertyInfo.GetValue(radioButtonList); 
     866                    }; 
     867                } 
     868            } 
     869 
     870 
     871            /// <summary> 
     872            /// 使用出来るかどうかを返します。 
     873            /// </summary> 
     874            /// <value> 
     875            /// 使用出来る場合は <see langword="true"/>。 
     876            /// それ以外の場合は <see langword="false"/>。 
     877            /// </value> 
     878            internal static bool IsValid 
     879            { 
     880                get 
     881                { 
     882                    return GetControlToRepeatDelegate != null; 
     883                } 
     884            } 
     885 
     886 
     887            /// <summary> 
     888            /// <c>RadioButtonList.ControlToRepeat</c> プロパティの値を取得します。 
     889            /// </summary> 
     890            /// <param name="radioButtonList"><see cref="System.Web.UI.WebControls.RadioButtonList"/>。</param> 
     891            /// <returns> 
     892            /// <c>RadioButtonList.ControlToRepeat</c> プロパティの値。 
     893            /// </returns> 
     894            internal static System.Web.UI.WebControls.RadioButton GetControlToRepeat(System.Web.UI.WebControls.RadioButtonList radioButtonList) 
     895            { 
     896                if (GetControlToRepeatDelegate == null) 
     897                { 
     898                    return null; 
     899                } 
     900 
     901                return GetControlToRepeatDelegate(radioButtonList); 
     902            } 
     903        } 
    628904    } 
    629905} 
  • framework/trunk/WebLibrary/Sources/UI/WebControls/RadioButtonList.cs

    r864 r1624  
    2323namespace FCSoft.SilverFrost.Framework.Web.UI.WebControls 
    2424{ 
     25    using System.Collections.Generic; 
     26    using System.Web.UI; 
     27    using System.Web.UI.WebControls; 
     28 
     29 
    2530    /// <summary> 
    2631    /// オプション ボタン コントロールのグループをカプセル化するリスト コントロールを表します。 
     
    3843            ControlInitializer.ApplyProperties(this); 
    3944        } 
     45 
     46 
     47        /// <summary> 
     48        /// <see cref="RadioButtonList" /> コントロール内のリスト項目を表示します。 
     49        /// </summary> 
     50        /// <param name="itemType"><see cref="ListItemType" /> 列挙値のいずれか。</param> 
     51        /// <param name="repeatIndex">リスト コントロールの項目の位置を指定する序数インデックス。</param> 
     52        /// <param name="repeatInfo">リストの項目を表示するために使用する情報を表す <see cref="RepeatInfo" />。</param> 
     53        /// <param name="writer">HTML コンテンツをクライアントに表示する出力ストリームを表す <see cref="HtmlTextWriter" />。</param> 
     54        protected override void RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer) 
     55        { 
     56            RegisterAutoPostBackClientScriptIfSelectedItem(repeatIndex); 
     57 
     58            // 親を呼び出す 
     59            base.RenderItem(itemType, repeatIndex, repeatInfo, writer); 
     60        } 
     61 
     62        /// <summary> 
     63        /// オートポストバックが有効で、選択されているアイテムの場合に対してクライアントスクリプトを登録します。 
     64        /// </summary> 
     65        /// <param name="repeatIndex">リスト コントロールの項目の位置を指定する序数インデックス。</param> 
     66        /// <remarks> 
     67        /// <para> 
     68        /// このコントロールでオートポストバックが有効になっている場合、 
     69        /// .NET 標準の実装 (4.8 時点) では、現在選択されているラジオボタンに対して、 
     70        /// ポストバックを行うクライアントスクリプトが登録されてません。 
     71        /// </para> 
     72        /// <para> 
     73        /// このコントロールが非同期ポストバック (<see cref="AsyncPostBackTrigger"/>) に登録されている場合、 
     74        /// 他のアイテムの選択によるポストバックが行われても、このコントロール自体はクライアント側では作成され直さないため、 
     75        /// クライアント側でレンダリングされたときのラジオボタンを再度選択してもポストバックが行われません。 
     76        /// </para> 
     77        /// <para> 
     78        /// このメソッドはそれに対応するために、選択済のラジオボタンに対してもポストバックを呼び出すクライアントスクリプトを登録します。 
     79        /// </para> 
     80        /// <para> 
     81        /// 注) この対応により、非同期ポストバックに登録されている場合、現在選択中のラジオボタンをクリックした場合にもポストバックが実行されます。 
     82        /// </para> 
     83        /// </remarks> 
     84        private void RegisterAutoPostBackClientScriptIfSelectedItem(int repeatIndex) 
     85        { 
     86            if (!AutoPostBack) 
     87            { 
     88                return; 
     89            } 
     90 
     91            Page page = Page; 
     92            if (page == null) 
     93            { 
     94                return; 
     95            } 
     96 
     97            ListItem item = Items[repeatIndex]; 
     98            if (!item.Selected) 
     99            { 
     100                return; 
     101            } 
     102 
     103            // AsyncPostBackControl として登録されていない場合 
     104            if (!IsRegisteredAsyncPostBackControl()) 
     105            { 
     106                return; 
     107            } 
     108 
     109            // リピートしてレンダリングするコントロールを取得 
     110            System.Web.UI.WebControls.RadioButton controlToRepeat 
     111                = Reflections.RadioButtonList.GetControlToRepeat(this); 
     112            if (controlToRepeat == null) 
     113            { 
     114                return; 
     115            } 
     116 
     117            const string OnClickAttributeName = "onclick"; 
     118            string onClick = item.Attributes[OnClickAttributeName]; 
     119 
     120            // controlToRepeat.ID を設定 (UniqueID と EnableLegacyRendering プロパティのみが使用される) 
     121            Reflections.ListControl.SetControlToRepeatId(this, controlToRepeat, repeatIndex); 
     122            PostBackOptions options = new PostBackOptions(controlToRepeat, string.Empty); 
     123 
     124            if (CausesValidation) 
     125            { 
     126                options.PerformValidation = true; 
     127                options.ValidationGroup = ValidationGroup; 
     128            } 
     129 
     130            if (page.Form != null) 
     131            { 
     132                options.AutoPostBack = true; 
     133            } 
     134 
     135            onClick = ClientScriptUtility.MergeScript(onClick, page.ClientScript.GetPostBackEventReference(options), false); 
     136            item.Attributes[OnClickAttributeName] = onClick; 
     137        } 
     138 
     139        /// <summary> 
     140        /// このコントロールが、非同期ポストバック (<see cref="AsyncPostBackTrigger"/>) に登録されているかどうかを返します。 
     141        /// </summary> 
     142        /// <returns> 
     143        /// このコントロールが、非同期ポストバック (<see cref="AsyncPostBackTrigger"/>) に登録されている場合は <see langword="true"/>。 
     144        /// それ以外の場合は <see langword="false"/>。 
     145        /// </returns> 
     146        private bool IsRegisteredAsyncPostBackControl() 
     147        { 
     148            Page page = Page; 
     149            if (page == null) 
     150            { 
     151                return false; 
     152            } 
     153 
     154            ScriptManager scriptManager = ScriptManager.GetCurrent(page); 
     155            if (scriptManager == null) 
     156            { 
     157                return false; 
     158            } 
     159 
     160            object pageRequestManager = Reflections.ScriptManager.GetPageRequestManager(scriptManager); 
     161            if (pageRequestManager == null) 
     162            { 
     163                return false; 
     164            } 
     165 
     166            List<Control> asyncPostBackControls = Reflections.PageRequestManager.GetAsyncPostBackControls(pageRequestManager); 
     167            if (asyncPostBackControls == null) 
     168            { 
     169                return false; 
     170            } 
     171 
     172            return asyncPostBackControls.Contains(this); 
     173        } 
    40174    } 
    41175} 
  • framework/trunk/WebTest/Sources/ReflectionsTest.cs

    r1622 r1624  
    187187            Assert.That(Reflections.SimpleBitVector32.Get(obj, Bit), Is.False, "3"); 
    188188        } 
     189 
     190        /// <summary> 
     191        /// <see cref="Reflections.ScriptManager"/> が使用出来るかのテストです。 
     192        /// </summary> 
     193        [Test] 
     194        public void TestScriptManagerIsValid() 
     195        { 
     196            Assert.That(Reflections.ScriptManager.IsValid, Is.True); 
     197        } 
     198 
     199        /// <summary> 
     200        /// <see cref="Reflections.PageRequestManager"/> が使用出来るかのテストです。 
     201        /// </summary> 
     202        [Test] 
     203        public void TestPageRequestManagerIsValid() 
     204        { 
     205            Assert.That(Reflections.PageRequestManager.IsValid, Is.True); 
     206        } 
     207 
     208        /// <summary> 
     209        /// <see cref="Reflections.ListControl"/> が使用出来るかのテストです。 
     210        /// </summary> 
     211        [Test] 
     212        public void TestListControlIsValid() 
     213        { 
     214            Assert.That(Reflections.ListControl.IsValid, Is.True); 
     215        } 
     216 
     217        /// <summary> 
     218        /// <see cref="Reflections.ListControl"/> の <c>SetControlToRepeatID</c> メソッドを呼び出すテストです。 
     219        /// </summary> 
     220        [Test] 
     221        public void TestListControlSetControlToRepeatId() 
     222        { 
     223            System.Web.UI.WebControls.RadioButtonList radioButtonList = new System.Web.UI.WebControls.RadioButtonList 
     224            { 
     225                ID = "RadioButtonList1", 
     226            }; 
     227 
     228            System.Web.UI.WebControls.RadioButton controlToRepeat = new System.Web.UI.WebControls.RadioButton(); 
     229 
     230            Assert.That(controlToRepeat.ID, Is.Null, "Before"); 
     231            Reflections.ListControl.SetControlToRepeatId(radioButtonList, controlToRepeat, 1); 
     232            Assert.That(controlToRepeat.ID, Is.Not.Empty, "After"); 
     233        } 
     234 
     235        /// <summary> 
     236        /// <see cref="Reflections.RadioButtonList"/> が使用出来るかのテストです。 
     237        /// </summary> 
     238        [Test] 
     239        public void TestRadioButtonListIsValid() 
     240        { 
     241            Assert.That(Reflections.RadioButtonList.IsValid, Is.True); 
     242        } 
     243 
     244        /// <summary> 
     245        /// <see cref="Reflections.RadioButtonList"/> の <c>ControlToRepeat</c> プロパティにアクセスするテストです。 
     246        /// </summary> 
     247        [Test] 
     248        public void TestRadioButtonListGetControlToRepeat() 
     249        { 
     250            Assert.That(Reflections.RadioButtonList.GetControlToRepeat(new System.Web.UI.WebControls.RadioButtonList()), Is.Not.Null); 
     251        } 
    189252    } 
    190253} 
詳しい使い方は TracChangeset を参照してください。