2

我正在使用 jquery 进行模式对话框。我想从一页打开模型对话框并将一些额外的查询字符串发送到模式对话框页面。像这样的东西:

 <asp:HyperLink ID="hypClientSearch" runat="server" NavigateUrl="~/SomePage.aspx?KeepThis=true&additionalQS='<%= txtBox.Text %>'&TB_iframe=true&height=650&width=800&modal=true" CssClass="thickbox" > 

这个例子不起作用。有谁知道解决方案?

4

2 回答 2

4

除了赫尔吉的回答。
如果您想使用 jQuery 获取文本框的值(当您需要使用其他选择器时使用 id),您可以使用:

var textBoxValue = $(textBoxSelector, window.opener.document).val();

编辑
哦,我刚刚注意到您使用的是模态。然后页面在 iFrame 中打开,您可以使用以下方法从 iFrame 中获取值:

var textBoxValue = $(textBoxSelector, window.parent.document).val();

此外,如果您需要在 iFrame 请求中将其发送到服务器,请尝试在单击时编辑链接的 href 属性:

$('#hypClientSearch').click( function() {
 var textBoxContent = $(textBoxSelector).val();
 $(this).attr('href', 'somepage.aspx?textbox='+textBoxContent+'&otherVarsForModal=foo');
 //we let the event bubble for the modal plugin, so ne returning false here
});
于 2009-04-10T09:47:09.177 回答
1

在模式对话框打开时尝试此操作(这是客户端 javascript):

var textBoxValue = window.opener.document.getElementById("txtBoxId").value;

然后,您使用 Javascript 将附加信息插入对话框中的正确位置,例如使用 JQuery。

于 2009-04-10T09:39:07.027 回答