.NET中利用js让子窗体向父页面传值
[csharp]
/// <summary>
/// 将设置好的值赋给父页面
/// </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);
}
父页面前台js:
[javascript]
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;
}
}
[javascript]
//弹出窗口
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;">
合格人数:
</th>
<td style="width: 50px;">
<:textbox id="txtqualifiednums" runat="server" width="50px" readonly="true"></asp:textbox>
</td>
上一篇: 怎么优化站内结构