ASP.NET 父页面取子页面的值
生活随笔
收集整理的這篇文章主要介紹了
ASP.NET 父页面取子页面的值
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
對(duì)JS不熟悉了,搞了一個(gè)多小時(shí),郁悶。
關(guān)閉子頁(yè)面,把子頁(yè)面的姓名文本框的值賦值給父頁(yè)面姓名文本框。
現(xiàn)在貼出代碼,供大家學(xué)習(xí)及自己備用。
父頁(yè)面名:ParentPage.aspx
JS腳本:?
主要是使用open打開子窗體。?
1???<script?type="text/javascript">2?????
3?????//打開子頁(yè)面
4??????function?openChild()
5??????{
6??????????window.open('ChildPage.aspx','子窗體','height=300');?
7??????}????????
8?????</script>
?
?HTML代碼:
1? 姓名<asp:TextBox?ID="txtName"?runat="server"></asp:TextBox>2?????????????<br?/>
3?????????????年齡<asp:TextBox?ID="txtAge"?runat="server"></asp:TextBox>
4?????????????<asp:Button?ID="btnSelect"?runat="server"?Text="請(qǐng)選擇"?OnClientClick="openChild() ;"?/>
5?????????????<br?/>
6?????????????性別<asp:DropDownList?ID="ddlSex"?runat="server">
7?????????????????<asp:ListItem?Text="男"?Selected="True"></asp:ListItem>
8?????????????????<asp:ListItem?Text="女"></asp:ListItem>
9?????????????</asp:DropDownList>
?
?子頁(yè)面名:ChildPage.aspx
?JS腳本:??
1????<script?type="text/javascript">???2?????//父頁(yè)面獲取子頁(yè)面的值
3??????function?getChildText()
4??????{
5??????????window.opener.document.getElementById('txtName').value=document.getElementById('txtC ? ? ? ? ? ?hildName').value; ???????
6?? ? ? ? ?window.close();
7?????}
8</script>
?
?HTML代碼:
1??姓名<asp:TextBox?ID="txtChildName"?runat="server"></asp:TextBox>2??<br?/>
4??<asp:Button?ID="btnClose"?runat="server"?Text="關(guān)閉刷新父窗體"?OnClientClick="getChildText()"/>
?
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/LeeYongze/archive/2010/06/24/1764582.html
總結(jié)
以上是生活随笔為你收集整理的ASP.NET 父页面取子页面的值的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: map的实现
- 下一篇: ASP.NET中String.Index