开发者

Modalpopup with UpdatePanel

开发者 https://www.devze.com 2023-03-25 03:06 出处:网络
I have an autocompleteextender that displays the list of countries. In the same textbox, when I type something and click on \"Search\" button, a pop-up should be opened and should display the matching

I have an autocompleteextender that displays the list of countries. In the same textbox, when I type something and click on "Search" button, a pop-up should be opened and should display the matching countries. I am using modalpopupextender for the popup.

aspx code:

     <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:Moda开发者_JAVA百科lPopupExtender> 

     </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> 

And in my codebehind:

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

I am not getting any countries in my popup, although I get results via my autocompleteextender. On clicking the imagebutton, I get the popup without any content. Pls help!


Place your popup contents inside panel like this:

<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>

and replace UpdatePanel's controls Id with this Panel's id:

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

and check if it works?


Try putting the extenders outside of the update panel, it should not be a child of what it is extending

0

精彩评论

暂无评论...
验证码 换一张
取 消