.NET中利用js讓子窗體向父頁面?zhèn)髦档膶?shí)現(xiàn)方法
更新時(shí)間:2013年02月26日 10:54:33 作者:
.NET中利用js讓子窗體向父頁面?zhèn)髦档膶?shí)現(xiàn)方法,需要的朋友可以參考一下
子頁面C#后臺(tái)代碼:
復(fù)制代碼 代碼如下:
/// <summary>
/// 將設(shè)置好的值賦給父頁面
/// </summary>
/// <param name="count">需要傳遞的值</param>
void SetValueToParentPage(int count, string strPersons)
{
StringBuilder jsStr = new StringBuilder();
jsStr.Append(" var retValue = new Object();");
if (count == 0)
{
jsStr.AppendFormat("retValue = null;");
}
else
{
jsStr.AppendFormat("retValue.Nums='{0}';", count);
jsStr.AppendFormat("retValue.Names='{0}';", strPersons);
}
jsStr.Append("window.returnValue = retValue;window.close();");
ClientScript.RegisterStartupScript(GetType(), "close", jsStr.ToString(), true);
}
父頁面前臺(tái)js:
復(fù)制代碼 代碼如下:
function OpenPerChoose(url) {
var openobj = window;
if (typeof (window.dialogArguments) == "object") {
openobj = window.dialogArguments;
}
var returnValue = showPopWin(url, 800, 600, openobj);
if (returnValue != null) {
document.getElementById("<%=txtQualifiedNums.ClientID %>").value = returnValue.Nums;
}
}
復(fù)制代碼 代碼如下:
//彈出窗口
function showPopWin(url, width, height, returnFunc) {
width = parseInt(width) + 30;
height = parseInt(height) + 30;
return window.showModalDialog(url + "&Datetime=" + GetTime(), document, "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:0;status:0;scroll:auto;center:1;resizable:1;");
}
<th style="width: 100px;">
培訓(xùn)合格人數(shù):
</th>
<td style="width: 50px;">
<asp:TextBox ID="txtQualifiedNums" runat="server" Width="50px" ReadOnly="true"></asp:TextBox>
</td>
相關(guān)文章
asp.net 漢字轉(zhuǎn)換拼音及首字母實(shí)現(xiàn)代碼
asp.net 漢字轉(zhuǎn)換拼音及首字母實(shí)現(xiàn)代碼,需要的朋友可以參考下。2011-12-12
asp.net 光棒效應(yīng)實(shí)現(xiàn)代碼
asp.net 光棒效應(yīng)(今天剛剛學(xué)到的)2009-12-12
Visual Studio中調(diào)試 .NET源代碼的實(shí)現(xiàn)步驟
在調(diào)試 .NET 應(yīng)用程序時(shí),有時(shí)你可能需要查看其他人的源代碼,本文主要介紹了Visual Studio中調(diào)試 .NET源代碼的實(shí)現(xiàn)步驟,具有一定的參考價(jià)值,感興趣的可以了解一下2024-03-03
在ASP.NET Core 中發(fā)送郵件的實(shí)現(xiàn)方法(必看篇)
下面小編就為大家?guī)硪黄贏SP.NET Core 中發(fā)送郵件的實(shí)現(xiàn)方法(必看篇)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-05-05
ASP.NET頁面借助IFrame提交表單數(shù)據(jù)所遇到問題的解決方法分享
ASP.NET頁面借助IFrame提交表單數(shù)據(jù)所遇到問題的解決方法分享,碰到同樣問題的朋友可以參考下。2011-10-10

