在父窗体中取得子窗体的返回值
WebForm1.aspx
Response.Write("<script language='javascript'>window.open(\"WebForm2.aspx\")</script>");
WebForm2.aspx
Response.Write("<script language='javascript'>window.open(\"WebForm2.aspx\")</script>");
WebForm2.aspx
<script language="javascript">
function na()
{
window.opener.document.getElementById("TextBox1").value="ddddd"; window.opener.document.getElementById("DropDownList1").options[0].value="dfdfdfdf"; window.opener.document.getElementById("DropDownList1").options[0].text="dfdfdfdf"; window.close();
}
</script>
pageload中function na()
{
window.opener.document.getElementById("TextBox1").value="ddddd"; window.opener.document.getElementById("DropDownList1").options[0].value="dfdfdfdf"; window.opener.document.getElementById("DropDownList1").options[0].text="dfdfdfdf"; window.close();
}
</script>
if(!Page.IsPostBack)
{
Button1.Attributes.Add("onClick","javascript:na()");
}
//但这样不会执行Button1里的代码
//改为
private void Button1_Click(object sender, System.EventArgs e)
{
string str = "<a href = 'javascript:na()'>,添加完成,返回!</a>";
Response.Write(str);
}
{
Button1.Attributes.Add("onClick","javascript:na()");
}
//但这样不会执行Button1里的代码
//改为
private void Button1_Click(object sender, System.EventArgs e)
{
string str = "<a href = 'javascript:na()'>,添加完成,返回!</a>";
Response.Write(str);
}
//这样传递三个参数,javascript方法中定义接受三个参数。Name,Type,Color为定义的变量
1.在任一事件中
string str = "<a href ='javascript:returnValueF(\""+Name+"\",\""+Type+"\",\""+Color+"\")'>添加成功,点击返回</a>";
Response.Write(str);
2.在PageLoad事件中
Button1.Attributes.Add("onClick","javascript:na('"+aaa+"','"+bbb+"','"+ccc+"')");
1.在任一事件中
string str = "<a href ='javascript:returnValueF(\""+Name+"\",\""+Type+"\",\""+Color+"\")'>添加成功,点击返回</a>";
Response.Write(str);
2.在PageLoad事件中
Button1.Attributes.Add("onClick","javascript:na('"+aaa+"','"+bbb+"','"+ccc+"')");