JS彈出對話框返回值代碼(asp.net后臺)
更新時間:2010年12月28日 22:19:55 作者:
JS彈出對話框返回值代碼,需要的朋友可以參考下。
1.Default.aspx頁面
<script type="text/javascript">
function GetUser(TxtEmpID,TxtEmpName,url)
{
var properties = 'status:no;resizable:no;toolbar=no;menubar=no;location=no;scroll:no;dialogWidth:540px;dialogHeight:450px;'
var arg=window.showModalDialog(url,"",properties);
if(arg!=null)
{
document.getElementById(TxtEmpID).value=arg[0];
document.getElementById(TxtEmpName).value=arg[1];
}
}
</script>
<table width="240px" cellpadding="0" cellspacing="0">
<tr>
<td style="width: 80px">
<asp:Label ID="Label1" runat="server" Text="選擇課級別一" Width="80px" class="font-w"></asp:Label></td>
<td style="width: 80px">
<asp:TextBox ID="TextBox1" runat="server" ReadOnly="false" Width="80px" onfocus="this.blur()"></asp:TextBox>
</td>
<td style="width: 80px">
<asp:TextBox ID="TextBox2" runat="server" ReadOnly="false" Width="80px" ></asp:TextBox>
</td>
<td style="width: 80px">
<asp:Button ID="Button1" runat="server" Text="確定" OnClick="Button1_Click" CssClass="ButtonCss"/>
</td>
<td>
<asp:Label ID="Label3" runat="server" Text=""></asp:Label></td>
<td> <asp:Label ID="Label4" runat="server" Text=""></asp:Label></td>
</tr>
</table>
2.Default.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Attributes.Add("onclick", "GetUser('" + this.TextBox1.ClientID + "','" + this.TextBox2.ClientID + "','WebDialog.aspx)");
}
3.WebDialog.aspx
<script language="javascript" type="text/javascript">
function Submit()
{
var arr=new Array();
arr[0]= document.getElementById('TxtEmpID').value
arr[1]= document.getElementById('TxtEmpCName').value
arr[2]= document.getElementById('TxtTitleID').value
window.returnValue=arr;
window.close();
}
</script>
<table>
<tr><td>
<asp:TextBox ID="TxtEmpID" runat="server" Width="50px" ReadOnly="true" CssClass="InputCss"></asp:TextBox>
<asp:TextBox ID="TxtEmpCName" runat="server" Width="60px" ReadOnly="true" CssClass="InputCss"></asp:TextBox>
<asp:TextBox ID="TxtTitleID" runat="server" Width="40px" ReadOnly="true" CssClass="InputCss"></asp:TextBox>
</tr></td>
<tr><td>
<input id="Button1" type="button" value="確 定" onclick="Submit()"/>
</tr></td>
</table>
復(fù)制代碼 代碼如下:
<script type="text/javascript">
function GetUser(TxtEmpID,TxtEmpName,url)
{
var properties = 'status:no;resizable:no;toolbar=no;menubar=no;location=no;scroll:no;dialogWidth:540px;dialogHeight:450px;'
var arg=window.showModalDialog(url,"",properties);
if(arg!=null)
{
document.getElementById(TxtEmpID).value=arg[0];
document.getElementById(TxtEmpName).value=arg[1];
}
}
</script>
<table width="240px" cellpadding="0" cellspacing="0">
<tr>
<td style="width: 80px">
<asp:Label ID="Label1" runat="server" Text="選擇課級別一" Width="80px" class="font-w"></asp:Label></td>
<td style="width: 80px">
<asp:TextBox ID="TextBox1" runat="server" ReadOnly="false" Width="80px" onfocus="this.blur()"></asp:TextBox>
</td>
<td style="width: 80px">
<asp:TextBox ID="TextBox2" runat="server" ReadOnly="false" Width="80px" ></asp:TextBox>
</td>
<td style="width: 80px">
<asp:Button ID="Button1" runat="server" Text="確定" OnClick="Button1_Click" CssClass="ButtonCss"/>
</td>
<td>
<asp:Label ID="Label3" runat="server" Text=""></asp:Label></td>
<td> <asp:Label ID="Label4" runat="server" Text=""></asp:Label></td>
</tr>
</table>
2.Default.aspx.cs
復(fù)制代碼 代碼如下:
protected void Page_Load(object sender, EventArgs e)
{
TextBox1.Attributes.Add("onclick", "GetUser('" + this.TextBox1.ClientID + "','" + this.TextBox2.ClientID + "','WebDialog.aspx)");
}
3.WebDialog.aspx
復(fù)制代碼 代碼如下:
<script language="javascript" type="text/javascript">
function Submit()
{
var arr=new Array();
arr[0]= document.getElementById('TxtEmpID').value
arr[1]= document.getElementById('TxtEmpCName').value
arr[2]= document.getElementById('TxtTitleID').value
window.returnValue=arr;
window.close();
}
</script>
<table>
<tr><td>
<asp:TextBox ID="TxtEmpID" runat="server" Width="50px" ReadOnly="true" CssClass="InputCss"></asp:TextBox>
<asp:TextBox ID="TxtEmpCName" runat="server" Width="60px" ReadOnly="true" CssClass="InputCss"></asp:TextBox>
<asp:TextBox ID="TxtTitleID" runat="server" Width="40px" ReadOnly="true" CssClass="InputCss"></asp:TextBox>
</tr></td>
<tr><td>
<input id="Button1" type="button" value="確 定" onclick="Submit()"/>
</tr></td>
</table>
您可能感興趣的文章:
- javascript web對話框與彈出窗口
- javascript form 驗證函數(shù) 彈出對話框形式
- JavaScript寫的一個DIV 彈出網(wǎng)頁對話框
- JavaScript寫的一個自定義彈出式對話框代碼
- ExtJS Ext.MessageBox.alert()彈出對話框詳解
- js中常用的彈出對話框3種方式
- js彈出模式對話框,并接收回傳值的方法
- 九種js彈出對話框的方法總結(jié)
- html+javascript實現(xiàn)可拖動可提交的彈出層對話框效果
- js showModalDialog 彈出對話框的簡單實例(子窗體)
- js彈出確認是否刪除對話框
- JavaScript彈出對話框的三種方式
相關(guān)文章
js 將canvas生成圖片保存,或直接保存一張圖片的實現(xiàn)方法
下面小編就為大家分享一篇js 將canvas生成圖片保存,或直接保存一張圖片的實現(xiàn)方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-01-01js利用遞歸與promise 按順序請求數(shù)據(jù)的方法
這篇文章主要介紹了js利用遞歸與promise 按順序請求數(shù)據(jù),需要的朋友可以參考下2019-08-08基于JS實現(xiàn)table導(dǎo)出Excel并保留樣式
這篇文章主要介紹了基于JS實現(xiàn)table導(dǎo)出Excel并保留樣式,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-05-05解決layer 關(guān)閉當前彈窗 關(guān)閉遮罩層 input值獲取不到的問題
今天小編就為大家分享一篇解決layer 關(guān)閉當前彈窗 關(guān)閉遮罩層 input值獲取不到的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-09-09uni-app常用的幾種頁面跳轉(zhuǎn)方式總結(jié)
uni-app的頁面跳轉(zhuǎn)和小程序和vue很相似,只是方法和標簽有所不同,這篇文章主要給大家介紹了關(guān)于uni-app常用的幾種頁面跳轉(zhuǎn)方式,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下2022-08-08JavaScript中for of和for in的區(qū)別詳解
對于初學(xué)者,我們或許只知道無論是for of還是for in他們都有一個功能那就是遍歷,至于具體的細節(jié)或許我們不是很清楚,那么接下來我們就來詳細的區(qū)分一下for of和for in他們之間的不同點和相同點,需要的朋友可以參考下2023-06-06JavaScript實現(xiàn)將數(shù)組中所有元素連接成一個字符串的方法
這篇文章主要介紹了JavaScript實現(xiàn)將數(shù)組中所有元素連接成一個字符串的方法,涉及javascript中采用join方法進行數(shù)組轉(zhuǎn)化的技巧,非常具有實用價值,需要的朋友可以參考下2015-04-04