日期:2014-05-18 浏览次数:20408 次
<script type="text/javascript" language="javascript"> <!-- var k = window.dialogArguments; //获得父窗口传递来的值 //关闭窗口返回是否刷新的参数. function winClose() { //var s = document.getElementById("<%=txbChild_sendToFather.ClientID%>").value; //我先把上面为变量 s 定义的代码注释掉,下面只为 s 赋了一个静态数字 100 var s = 100; window.returnValue = s; window.close(); } //--> </script>
<input type ="button" value="关闭且返回值" onclick="winClose()" /> <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="关闭且返回值" />
protected void Button1_Click(object sender, EventArgs e) { this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), Guid.NewGuid().ToString(), "winClose();", true); }
<script type="text/javascript" language="javascript"> <!-- var k = window.dialogArguments; //获得父窗口传递来的值 //关闭窗口返回是否刷新的参数. function winClose() { //var s = 100; //我把 var s 定义由静态数字 100 改为 取得 textbox 值 var s = document.getElementById("<%=txbChild_sendToFather.ClientID%>").value; window.returnValue = s; window.close(); } //--> </script>
protected void Button1_Click(object sender, EventArgs e) { System.Text.StringBuilder cstext2 = new System.Text.StringBuilder(); cstext2.Append(string.Format("<script type=text/javascript>var s ='{0}'; ",txbChild_sendToFather.Text.ToString())); cstext2.Append("window.returnValue = s;window.close();</"); cstext2.Append("script>"); Response.Write(string.Format("{0}",cstext2.ToString())); }