【问题标题】:Pass query string to Modal Pop Up将查询字符串传递给 Modal Pop Up
【发布时间】:2013-07-03 13:24:34
【问题描述】:

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

  <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)我该怎么做?

【问题讨论】:

  • 您可以通过更改 iframe 的 src 来做到这一点,例如 "Check_Patient.aspx?id=123"

标签: asp.net ajax modalpopupextender


【解决方案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”事件,使其在更改后仍然存在。通过将文本框的值附加为查询字符串,将 iframe 的“src”属性设置为新的 url。

【讨论】:

  • 考虑对您的答案进行一些解释,以帮助那些不熟悉的人。
  • @DonBoitnott 已修复。谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-11-15
  • 2012-04-14
  • 2012-06-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多