父页面前台:
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
<br />
</asp:Content>
父页面后台:
protected void Page_Load(object sender, EventArgs e)
{
//循环每个TextBox并为其加入ondblclick属性)
for (int i = 1; i < 3; i++)
{
ContentPlaceHolder cphUp = (ContentPlaceHolder)Master.FindControl("ContentPlaceHolder1");
TextBox fz = cphUp.FindControl("TextBox" + i) as TextBox;
fz.Attributes.Add("ondblclick", "window.open('StyleWindowZi.aspx?textid=" + fz.ClientID + "','dsfa','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=740,height=460,left='+(screen.width-700)/2+',top='+(screen.height-460)/2);return false");
}
}
子页面StyleWindowZi.aspx前台:
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<script type="text/javascript">
function ReKey(k)//页面间传值
{
window.opener.document.getElementById('<%=Request.QueryString["textid"] %>').value=k;//将得到的k的值传给父页
window.close();
}
</script>
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem Value="s">s</asp:ListItem>
<asp:ListItem Value="ss">ss</asp:ListItem>
<asp:ListItem Value="sss">sss</asp:ListItem>
</asp:DropDownList>
<br />
<asp:Button ID="Button1" runat="server" Text="Button"
οnclick="Button1_Click1" />
</asp:Content>
子页面后台:
public string checkedName()
{
string z = "";
z = DropDownList1.SelectedValue;
return z;
}
protected void Button1_Click1(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(ClientScript.GetType(), "myscript", "<script>ReKey('" + checkedName() + "');</script>");
}