将查询字符串传递给Modal Pop Up

时间:2013-07-05 12:27:49

标签: asp.net ajax modalpopupextender

这就是我的模态弹出窗口的样子

  <asp:TextBox ID="txtPatientID" AutoCompleteType="Disabled" runat="server" CssClass="csstextbox" Width="350px"></asp:TextBox>      

             <asp:Button ID="btnCheckPatientID" CssClass="cssbutton" runat="server" Text="Check" />
                                    <asp:ModalPopupExtender ID="btnCheckPatientID_ModalPopupExtender" runat="server"
                                        PopupControlID="panelCheckPatient" TargetControlID="btnCheckPatientID" BackgroundCssClass="modalbackground">
                                    </asp:ModalPopupExtender>            

            <div class="modalpopup" id="panelCheckPatient" style="display: none">
                                <iframe id="iframeCheckPatient" runat="server" width="485px" src="Check_Patient.aspx"
                                    height="485px" scrolling="auto"></iframe>

                            </div>

单击btnCheckPatientID我必须将txtPatientID.Text传递为查询字符串传递给Modalpopup(在modalpopup中加载iframe)我该怎么做?

1 个答案:

答案 0 :(得分:1)

您可以使用jQuery执行此操作:

$('#btnCheckPatientID').live("click", function() {
    // your existing page
    var url = "Check_Patient.aspx";
    // append value of textbox as querystring
    var newUrl = url + "?id=" + $('#txtPatientID').val();
    // update the src attribute of your iframe with the newUrl
    $('#iframeCheckPatient').attr("src", newUrl);
});

使用“live”绑定按钮的“click”事件,以便它能够幸免于变化。通过将textbox的值附加为查询字符串,将iframe的“src”属性设置为新的url。