1

3 つのテキスト ボックスと 2 つのボタンを持つパネルを含むモーダル ポップアップ エクステンダーを使用しています。テキストボックスの値に仕様(選択した日付)を入力したいのですが、うまく取得できません。

protected void myCal_SelectionChanged(object sender, EventArgs e)
    {
        ModalPopupExtender1.Show();
        TextBoxStart.Text = myCal.SelectedDate.ToString();
        TextBoxEnd.Text = myCal.SelectedDate.ToString();
    }

デザイナーは

<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">

  <ContentTemplate>        
      <asp:Calendar ID="myCal" runat="server" Height="600px" width="900px" 
        BorderColor="#F2F3F4" BorderWidth="3px" DayStyle-BorderWidth="1px" 
                TodayDayStyle-BackColor="#82CAFF" NextPrevFormat="ShortMonth" 
        SelectionMode="Day" DayHeaderStyle-Height="30px" 
                TitleStyle-BackColor="#CBE3F0" TitleStyle-ForeColor="#153E7E" 
        OtherMonthDayStyle-ForeColor="#B4CFEC" NextPrevStyle-ForeColor="#2554C7" 
        CssClass="mGrid" onselectionchanged="myCal_SelectionChanged">
        <DayHeaderStyle Height="30px" /><TitleStyle Height="50px" />
        <DayStyle BorderWidth="1px" HorizontalAlign="Left" VerticalAlign="Top" />
        <TodayDayStyle BackColor="#CBE3F0" />
    </asp:Calendar>

      <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="ButtonDummy" PopupControlID="pnlSelect">

      </ajaxToolkit:ModalPopupExtender>

</ContentTemplate>

      </asp:UpdatePanel>


    <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Always">
<ContentTemplate>

       <asp:Panel ID="pnlSelect" runat="server" width="200px" Height="200px">

           <table border="0" cellspacing="6" cellpadding="0" style="background-color: white">
               <tr>
                   <td align="right"></td>
                   <td>
                       <h2>New Appointment</h2>
                   </td>
               </tr>
               <tr>
                   <td align="right">Start Date:</td>
                   <td>
                       <asp:TextBox ID="TextBoxStart" runat="server"></asp:TextBox></td>
               </tr>
               <tr>
                   <td align="right">End Date:</td>
                   <td>
                       <asp:TextBox ID="TextBoxEnd" runat="server"></asp:TextBox></td>
               </tr>
               <tr>
                   <td align="right">Name:</td>
                   <td>
                       <asp:TextBox ID="TextBoxName" runat="server"></asp:TextBox></td>
               </tr>
               <tr>
                   <td align="right"></td>
                   <td>
                       <asp:Button ID="ButtonOK" runat="server" OnClick="ButtonOK_Click" Text="OK" />
                       <asp:Button ID="ButtonCancel" runat="server" Text="Cancel" OnClick="ButtonCancel_Click" />
                   </td>
               </tr>
           </table>

       </asp:Panel>
    </ContentTemplate>

何が間違っている可能性がありますか?

4

1 に答える 1

2

これらのテキストボックスはUpdatePanelの外に配置されているため、非同期要求では更新されません。それらを同じUpdatePanelに配置するか、別のUpdatePanelでラップして、以下のようにUpdateModeを「Always」に設定します。

<asp:UpdatePanel runat="server" UpdateMode="Always">
    <ContentTemplate>
        <asp:Panel runat="server" ID="pnlSelect" >
            <asp:TextBox runat="server" ID="TextBoxStart" />
            <asp:TextBox runat="server" ID="TextBoxEnd" />
        </asp:Panel>
    </ContentTemplate>
</asp:UpdatePanel>

ChildrenAsTriggersUpdatePanel1のプロパティをUpdatePanel2に設定するtrueか、ModalPopupExtender1をUpdatePanel2に移動してみてください。

また、PopupExtenderとそのターゲットダミーボタンをUpdatePanel1から移動し、pnlSelectをUpdatePanel2と交換することもできます。

<asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional" ChildrenAsTriggers="false">
    <ContentTemplate>
        <asp:Button ID="Button1" runat="server" Text="Click Me" />
    </ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="ButtonDummy" runat="server" Style="display: none" />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="ButtonDummy"
    PopupControlID="pnlSelect" BackgroundCssClass="modalBackground" />
<asp:Panel ID="pnlSelect" runat="server" Style="display: none" CssClass="modalPopup">
    <asp:UpdatePanel runat="server" ID="UpdatePanel2" UpdateMode="Always">
        <ContentTemplate>
            <asp:TextBox runat="server" ID="TextBoxStart" />
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Panel>
于 2012-09-20T10:13:25.927 に答える