在cs页面中用代码弹出showModalDialog窗口,如何传值给父窗口

cycc 2013-05-08 03:04:09
我在CS代码中使用 ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "cy1", "window.showModalDialog('" + "../Pop-up-window/GoodsSize.aspx?GoodsID=" + HiddenFieldGoodsId.Value.Trim() + "');", true);弹出了一个showModalDialog窗口,但是我在CS代码中执行给父窗口传值时提示return window.dialogArguments.document.getElementById(id); 这个值为空。

下面是从弹窗传值到父窗体的代码:
ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "cy1", "var parDocument=function $(id){ return window.dialogArguments.document.getElementById(id); };", true);
ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "cy2", "if(parDocument('ctl00_ContentPlaceHolder1_TextBoxQuantity')!=null){parDocument('ctl00_ContentPlaceHolder1_TextBoxQuantity').value = '" + quantity + "';};", true);
ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "cy0", "self.close();", true);

我估计是上面的弹窗代码没有把交窗口的相关属性传过来,但是我又不知道怎么在上面那个弹窗代码中加上 相关的属性代码。使父窗体能获取到用这个方法弹出的子窗体的值。


...全文
61 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
rayaspnet 2013-05-08
  • 打赏
  • 举报
回复
引用 楼主 cycc 的回复:
我在CS代码中使用 ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "cy1", "window.showModalDialog('" + "../Pop-up-window/GoodsSize.aspx?GoodsID=" + HiddenFieldGoodsId.Value.Trim() + "');", true);弹出了一个showModalDialog窗口,但是我在CS代码中执行给父窗口传值时提示return window.dialogArguments.document.getElementById(id); 这个值为空。 下面是从弹窗传值到父窗体的代码: ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "cy1", "var parDocument=function $(id){ return window.dialogArguments.document.getElementById(id); };", true); ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "cy2", "if(parDocument('ctl00_ContentPlaceHolder1_TextBoxQuantity')!=null){parDocument('ctl00_ContentPlaceHolder1_TextBoxQuantity').value = '" + quantity + "';};", true); ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "cy0", "self.close();", true); 我估计是上面的弹窗代码没有把交窗口的相关属性传过来,但是我又不知道怎么在上面那个弹窗代码中加上 相关的属性代码。使父窗体能获取到用这个方法弹出的子窗体的值。
最好用jquery 和javascript 直接写 ajax。 这样比较容易调试, 和明白 每个步骤发生的序列关系。 scriptmanager 和 updatepanel 很容易混淆基本概念
cycc 2013-05-08
  • 打赏
  • 举报
回复
????????没有人回复??

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧