使用UpdatePanel的Modalpopup

时间:2011-08-02 07:17:06

标签: asp.net

我有一个autocompleteextender,显示国家/地区列表。在同一文本框中,当我输入内容并单击“搜索”按钮时,应打开一个弹出窗口并显示匹配的国家/地区。我正在使用modalpopupextender进行弹出窗口。

aspx代码:

     <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
       <contenttemplate>
         <asp:TextBox id="TextBox1" runat="server" Width="250px"></asp:TextBox>
         <asp:ImageButton id="ImageButton1" onclick="imgBtnSearch_Click" runat="server" ImageUrl="~/Images/Lab/search.jpg"></asp:ImageButton>
         <cc1:AutoCompleteExtender id="TextBox1_AutoCompleteExtender" runat="server" EnableCaching="true" CompletionSetCount="10" MinimumPrefixLength="1" ServicePath="AutoComplete.asmx" UseContextKey="True" TargetControlID="TextBox1" ServiceMethod="GetCountryInfo">
        </cc1:AutoCompleteExtender> 
         <cc1:ModalPopupExtender id="ModalPopupExtender1" runat="server" TargetControlID="ImageButton1" BackgroundCssClass="ModalPopupBG" Drag="true" PopupDragHandleControlID="PopupHeader" PopupControlID="updatePanel2"  CancelControlID="btnCancel" ></cc1:ModalPopupExtender> 

     </contenttemplate>
     </asp:UpdatePanel>
  <asp:UpdatePanel id="updatePanel2" runat="server" UpdateMode="Conditional">
         <ContentTemplate>
                     <asp:RadioButtonList id="RadioButtonList1" runat="server" Width="400" Height="400" RepeatColumns="5" RepeatLayout="Table" RepeatDirection="Vertical" AutoPostBack="True"></asp:RadioButtonList> 

            <DIV class="Controls">
                <INPUT id="btnOk" type="button" value="OK" />
                <INPUT id="btnCancel" type="button" value="Cancel" />
            </DIV>

        </ContentTemplate>
        <Triggers>
        <asp:AsyncPostBackTrigger ControlID="ImageButton1" EventName="Click"></asp:AsyncPostBackTrigger>
        </Triggers>
    </asp:UpdatePanel> 

在我的代码隐藏中:

 protected void imgBtnSearch_Click(object sender, ImageClickEventArgs e) 
 {
   LoadCountryPopUp();
   ModalPopupExtender1.Show();
 }

虽然我通过autocompleteextender获得了结果,但我的弹出窗口中没有任何国家/地区。单击图像按钮,我得到没有任何内容的弹出窗口。请帮助!

2 个答案:

答案 0 :(得分:0)

将弹出内容放在面板中,如下所示:

<asp:UpdatePanel id="updatePanel2" runat="server" UpdateMode="Conditional">
         <ContentTemplate>
<asp:Panel id="pnlPopup" runat="server">
                     <asp:RadioButtonList id="RadioButtonList1" runat="server" Width="400" Height="400" RepeatColumns="5" RepeatLayout="Table" RepeatDirection="Vertical" AutoPostBack="True"></asp:RadioButtonList> 

            <DIV class="Controls">
                <INPUT id="btnOk" type="button" value="OK" />
                <INPUT id="btnCancel" type="button" value="Cancel" />
            </DIV>
</Panel>
        </ContentTemplate>
        <Triggers>
        <asp:AsyncPostBackTrigger ControlID="ImageButton1" EventName="Click"></asp:AsyncPostBackTrigger>
        </Triggers>
    </asp:UpdatePanel>

并用此Panel的id替换UpdatePanel的控件ID:

<cc1:ModalPopupExtender id="ModalPopupExtender1" runat="server" TargetControlID="ImageButton1" BackgroundCssClass="ModalPopupBG" Drag="true" PopupDragHandleControlID="PopupHeader" PopupControlID="pnlPopup"  CancelControlID="btnCancel" ></cc1:ModalPopupExtender>

并检查它是否有效?

答案 1 :(得分:-1)

尝试将扩展程序放在更新面板之外,它不应该是扩展程序的子项