JS彈出對(duì)話框返回值代碼(asp.net后臺(tái))
更新時(shí)間:2010年12月28日 22:19:55 作者:
JS彈出對(duì)話框返回值代碼,需要的朋友可以參考下。
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="選擇課級(jí)別一" 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="選擇課級(jí)別一" 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對(duì)話框與彈出窗口
- javascript form 驗(yàn)證函數(shù) 彈出對(duì)話框形式
- JavaScript寫的一個(gè)DIV 彈出網(wǎng)頁對(duì)話框
- JavaScript寫的一個(gè)自定義彈出式對(duì)話框代碼
- ExtJS Ext.MessageBox.alert()彈出對(duì)話框詳解
- js中常用的彈出對(duì)話框3種方式
- js彈出模式對(duì)話框,并接收回傳值的方法
- 九種js彈出對(duì)話框的方法總結(jié)
- html+javascript實(shí)現(xiàn)可拖動(dòng)可提交的彈出層對(duì)話框效果
- js showModalDialog 彈出對(duì)話框的簡單實(shí)例(子窗體)
- js彈出確認(rèn)是否刪除對(duì)話框
- JavaScript彈出對(duì)話框的三種方式
相關(guān)文章
JavaScript進(jìn)階教程之函數(shù)的定義、調(diào)用及this指向問題詳解
這篇文章主要給大家介紹了關(guān)于JavaScript進(jìn)階教程之函數(shù)的定義、調(diào)用及this指向問題的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用js具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2022-09-09
JavaScript移動(dòng)端常用事件之touch觸摸事件詳解
觸屏事件touch也稱為觸摸事件,touch對(duì)象代表一個(gè)觸摸點(diǎn),觸摸點(diǎn)可能是一根手指,也可能是一根觸摸筆,觸屏事件可響應(yīng)用戶手指(或觸摸筆)對(duì)屏幕或者觸控板操作,下面這篇文章主要給大家介紹了關(guān)于JavaScript移動(dòng)端常用事件之touch觸摸事件的相關(guān)資料,需要的朋友可以參考下2022-10-10
JavaScript基礎(chǔ)之文件上傳與下載的實(shí)現(xiàn)詳解
這篇文章主要為大家詳細(xì)介紹了JavaScript實(shí)現(xiàn)文件上傳與下載功能的相關(guān)資料,文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,感興趣的小伙伴可以學(xué)習(xí)一下2023-01-01
如何通過JS實(shí)現(xiàn)轉(zhuǎn)碼與解碼
這篇文章主要介紹了如何通過JS實(shí)現(xiàn)轉(zhuǎn)碼與解碼,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-02-02
javascript判斷css3動(dòng)畫結(jié)束 css3動(dòng)畫結(jié)束的回調(diào)函數(shù)
本文主要給大家介紹的是如何使用javascript判斷CSS3動(dòng)畫效果結(jié)束,主要是使用了javascript的回調(diào)函數(shù),其思路是一旦動(dòng)畫或變換結(jié)束,回調(diào)函數(shù)就會(huì)觸發(fā)。不再需要大型類庫支持,非常的簡單實(shí)用,推薦給大家。2015-03-03
JavaScript中附件預(yù)覽功能實(shí)現(xiàn)詳解(推薦)
這篇文章主要介紹了JavaScript中附件預(yù)覽功能的實(shí)現(xiàn),具體操作步驟大家可查看下文詳細(xì)講解,感興趣的小伙伴們可以參考一下。2017-08-08
JS實(shí)現(xiàn)表單多文件上傳樣式美化支持選中文件后刪除相關(guān)項(xiàng)
在項(xiàng)目開發(fā)中我們經(jīng)常遇到文件上傳的功能,根據(jù)需求有多文件上傳和單文件上傳,今天小編給大家實(shí)例講解下表單多文件上傳樣式美化支持選中文件后刪除相關(guān)項(xiàng),非常不錯(cuò),感興趣的朋友一起看看吧2016-09-09

