asp.net内联框架父页面如何调用子页面中控件值

liulucy2017 2017-08-03 04:04:16
我用asp.net建立了一个网站,利用iframe内联框架实现了页面嵌套功能,在导航栏中点击不同选项,会呈现不同子页面
现在在父级页面中有一个button按钮,子页面中有textbox等等一系列控件,希望在子页面中进行一系列操作后,其控件值能够传递到父级页面中
...全文
447 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
liulucy2017 2017-08-07
  • 打赏
  • 举报
回复
引用 19 楼 insus 的回复:
是的,它是一个接口类,你需要使用interface修饰符。 可以单独写好编译为dll,然后引用至bin目录中。也可以写在App_Code目录中。你的程序能访问到即可。
解决了之前提的问题,还有一个新的问题,这个接口只能用于母版页对子页的调用吗?能否用于iframe框架嵌套中的调用。 因为我的母页中还有一些控件,希望点击不同子页时不必再重新输入控件值,但使用母版页换页时所有控件值都刷新了
insus 2017-08-07
  • 打赏
  • 举报
回复
是的,它是一个接口类,你需要使用interface修饰符。

可以单独写好编译为dll,然后引用至bin目录中。也可以写在App_Code目录中。你的程序能访问到即可。


liulucy2017 2017-08-07
  • 打赏
  • 举报
回复
引用 17 楼 insus 的回复:
可以参考这里: http://www.cnblogs.com/insus/p/7291543.html
弱弱地再问一个问题,IgetSubpageContenable.cs是类吗?这个文件应该写在哪里
insus 2017-08-07
  • 打赏
  • 举报
回复
liulucy2017 2017-08-06
  • 打赏
  • 举报
回复
[quote=引用 15 楼 insus 的回复:] 当然没有问题。 子页将有很多,形式也将各不相同。而父页只有一个。 因此需要你的决定,各子反回的数据是怎样的。 求大神贴出这段代码!!!
insus 2017-08-05
  • 打赏
  • 举报
回复
当然没有问题。

子页将有很多,形式也将各不相同。而父页只有一个。
因此需要你的决定,各子反回的数据是怎样的。

  • 打赏
  • 举报
回复
引用 4 楼 liulucy2017 的回复:
[quote=引用 2 楼 foren_whb 的回复:] asp.net有布局页分部页,就不需要iframe了,这东西太落后太坑爹了,最好别用
布局页分布页怎么使用? 能给个例子吗?[/quote]parent就是父页的window对象,自己随便操作,只要没跨域 ==》iframe和父页,window.open打开页面之间的引用
liulucy2017 2017-08-04
  • 打赏
  • 举报
回复
引用 2 楼 foren_whb 的回复:
asp.net有布局页分部页,就不需要iframe了,这东西太落后太坑爹了,最好别用
布局页分布页怎么使用? 能给个例子吗?
  • 打赏
  • 举报
回复
引用 12 楼 liulucy2017 的回复:
[quote=引用 11 楼 showbo 的回复:] [quote=引用 10 楼 liulucy2017 的回复:] 按您说的进行修改,呈现图中效果,但我希望的是能让label获取值
楼主多学习下js了,这么简单的。而且不要老用服务器端控件,要了解下客户端控件用法,服务器端控件最终都会转化为客户端控件,就是html代码 <asp:Label ID="Label1" runat="server" Text="Label" onClientClick="this.innerHTML=document.getElementById('iframe1').contentWindow.document.getElementById('DropDownList1').value"></asp:Label>[/quote] 嗯,打算是要好好研究一下JS,上述代码运行还是没有反应啊,何况label本来也没有onclientclick属性啊[/quote]这个是设置客户端控件的onclick事件的,所以要你了解下客户端控件
liulucy2017 2017-08-04
  • 打赏
  • 举报
回复
引用 8 楼 insus 的回复:
或者: http://www.cnblogs.com/insus/archive/2012/02/22/2362830.html
您这个是内容页调用母版页的控件值,我想实现的正相反,刚刚根据您这个代码改了一下,反过来就报错,不知您是否知道反过来调用应该如何写?
liulucy2017 2017-08-04
  • 打赏
  • 举报
回复
引用 11 楼 showbo 的回复:
[quote=引用 10 楼 liulucy2017 的回复:] 按您说的进行修改,呈现图中效果,但我希望的是能让label获取值
楼主多学习下js了,这么简单的。而且不要老用服务器端控件,要了解下客户端控件用法,服务器端控件最终都会转化为客户端控件,就是html代码 <asp:Label ID="Label1" runat="server" Text="Label" onClientClick="this.innerHTML=document.getElementById('iframe1').contentWindow.document.getElementById('DropDownList1').value"></asp:Label>[/quote] 嗯,打算是要好好研究一下JS,上述代码运行还是没有反应啊,何况label本来也没有onclientclick属性啊
  • 打赏
  • 举报
回复
引用 10 楼 liulucy2017 的回复:
按您说的进行修改,呈现图中效果,但我希望的是能让label获取值
楼主多学习下js了,这么简单的。而且不要老用服务器端控件,要了解下客户端控件用法,服务器端控件最终都会转化为客户端控件,就是html代码 <asp:Label ID="Label1" runat="server" Text="Label" onClientClick="this.innerHTML=document.getElementById('iframe1').contentWindow.document.getElementById('DropDownList1').value"></asp:Label>
liulucy2017 2017-08-04
  • 打赏
  • 举报
回复
引用 9 楼 showbo 的回复:
[quote=引用 6 楼 liulucy2017 的回复:] [quote=引用 5 楼 showbo 的回复:] [quote=引用 4 楼 liulucy2017 的回复:] [quote=引用 2 楼 foren_whb 的回复:] asp.net有布局页分部页,就不需要iframe了,这东西太落后太坑爹了,最好别用
布局页分布页怎么使用? 能给个例子吗?[/quote]parent就是父页的window对象,自己随便操作,只要没跨域 ==》iframe和父页,window.open打开页面之间的引用[/quote] 举例说明:父页面前台代码如下 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> </div><div> <iframe id="iframe1" src="Default2.aspx" style="height:3000px;width:100%;border:hidden" name="shouye" ></iframe></div> </form> </body> </html> 子页面前台代码如下: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:DropDownList ID="DropDownList1" runat="server"> <asp:ListItem>重庆</asp:ListItem> <asp:ListItem>山东</asp:ListItem> </asp:DropDownList> </div> </form> </body> </html> 要怎么写才能使点击按钮时label获取dropdownlist中的取值呢 [/quote] <asp:Label ID="Label1" runat="server" Text="Label" onClientClick="alert(document.getElementById('iframe1').contentWindow.document.getElementById('DropDownList1').value)"></asp:Label>[/quote] 按您说的进行修改,呈现图中效果,但我希望的是能让label获取值
  • 打赏
  • 举报
回复
引用 6 楼 liulucy2017 的回复:
[quote=引用 5 楼 showbo 的回复:] [quote=引用 4 楼 liulucy2017 的回复:] [quote=引用 2 楼 foren_whb 的回复:] asp.net有布局页分部页,就不需要iframe了,这东西太落后太坑爹了,最好别用
布局页分布页怎么使用? 能给个例子吗?[/quote]parent就是父页的window对象,自己随便操作,只要没跨域 ==》iframe和父页,window.open打开页面之间的引用[/quote] 举例说明:父页面前台代码如下 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> </div><div> <iframe id="iframe1" src="Default2.aspx" style="height:3000px;width:100%;border:hidden" name="shouye" ></iframe></div> </form> </body> </html> 子页面前台代码如下: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:DropDownList ID="DropDownList1" runat="server"> <asp:ListItem>重庆</asp:ListItem> <asp:ListItem>山东</asp:ListItem> </asp:DropDownList> </div> </form> </body> </html> 要怎么写才能使点击按钮时label获取dropdownlist中的取值呢 [/quote] <asp:Label ID="Label1" runat="server" Text="Label" onClientClick="alert(document.getElementById('iframe1').contentWindow.document.getElementById('DropDownList1').value)"></asp:Label>
liulucy2017 2017-08-04
  • 打赏
  • 举报
回复
引用 5 楼 showbo 的回复:
[quote=引用 4 楼 liulucy2017 的回复:] [quote=引用 2 楼 foren_whb 的回复:] asp.net有布局页分部页,就不需要iframe了,这东西太落后太坑爹了,最好别用
布局页分布页怎么使用? 能给个例子吗?[/quote]parent就是父页的window对象,自己随便操作,只要没跨域 ==》iframe和父页,window.open打开页面之间的引用[/quote] 举例说明:父页面前台代码如下 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> </div><div> <iframe id="iframe1" src="Default2.aspx" style="height:3000px;width:100%;border:hidden" name="shouye" ></iframe></div> </form> </body> </html> 子页面前台代码如下: <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:DropDownList ID="DropDownList1" runat="server"> <asp:ListItem>重庆</asp:ListItem> <asp:ListItem>山东</asp:ListItem> </asp:DropDownList> </div> </form> </body> </html> 要怎么写才能使点击按钮时label获取dropdownlist中的取值呢
丰云 2017-08-03
  • 打赏
  • 举报
回复
如果你的客户全部都是用的ie浏览器,并且版本还都一致,那还好,否则,你就等着以后哭吧
丰云 2017-08-03
  • 打赏
  • 举报
回复
asp.net有布局页分部页,就不需要iframe了,这东西太落后太坑爹了,最好别用
及时雨送浆 2017-08-03
  • 打赏
  • 举报
回复
js? 父页面中: window.frame[0].fun(); 子页面中:fun() { alert('ok'); }

62,266

社区成员

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

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

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

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