比如你的子窗口用window.showModalDialog(.......) 打开你在子窗口里定义 window.top.returnValue = ***;(***是你要传的值)在父窗口里定义一个变量接收就可以了 var val = window.showModalDialog(.....)不知道这样说你明白 呵呵:)
解决方案 »
- 如何把window.open改成window.showModalDialog
- js中数组的问题
- 导航菜单指定位置!! 在线等,马上给分
- 请教一个问题,高手请进
- 数据库更新级联菜单的问题,怎么样从下拉列表获得的value或者text中取数据进行查询?(解决就送分)
- 求,在javascript如何对一个数值取两位小数的格式
- 哪位有JavaScript 电子书给小弟看一下好吗?
- (100分)很急,问一个可能是javascript很简单应用问题,希望要有代码
- 我想用javascript实现定时执行一个程序,但是页面不刷新,请问javascript能否做到?急,急!!
- Ext4 调用RowEditing的StartEdit之后,ComboBox显示值的问题
- 关于marquee无间断滚动效果处理动态数据的问题,请高手指点!!!!!严重感谢!!急,谁帮我解决我再开帖送500分
- 关于日期的问题,拜托大家帮忙了,急,分不够可加
1.弹出窗口html<%@ Page language=c# Codebehind=Web_Dialog_Customer.aspx.cs AutoEventWireup=false Inherits=PI.Web_Dialog_Customer %>
<!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.0 Transitional//EN >
<HTML>
<HEAD>
<title>Web_Dialog_Customer</title>
<META http-equiv=”Pragma” content=”no-cache”>
<META http-equiv=”Cache-Control” content=”no-cache”>
<meta content=Microsoft Visual Studio .NET 7.1 name=GENERATOR>
<meta content=C# name=CODE_LANGUAGE>
<meta content=JavaScript name=vs_defaultClientScript>
<meta content=http://schemas.microsoft.com/intellisense/ie5 name=vs_targetSchema>
<base target=_self>
</HEAD>
<body bgColor=#f2f2f1 MS_POSITIONING=GridLayout>
<form id=Form1 method=post runat=server>
<FONT face=宋体>
<asp:datagrid id=DataGrid1 style=Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px runat=server
Height=168px CellPadding=1 BorderColor=Black BorderWidth=1px Font-Size=9pt Font-Names=宋体
ShowFooter=True AutoGenerateColumns=False Width=248px>
<HeaderStyle HorizontalAlign=Center Height=30px ForeColor=Black VerticalAlign=Middle
BackColor=WhiteSmoke></HeaderStyle>
<Columns>
<asp:BoundColumn Visible=False DataField=cust_no ReadOnly=True HeaderText=客户代码></asp:BoundColumn>
<asp:TemplateColumn HeaderText=客户名称>
<ItemTemplate>
<asp:TextBox id=txt_cust_name runat=server Width=240px Height=24px Text='<%# DataBinder.Eval(Container, DataItem.cust_name) %>'>
</asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid></FONT></form>
</body>
</HTML>
弹出窗口cs
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;namespace PI
{
/// <summary>
/// Web_Dialog_Customer 的摘要说明。
/// </summary>
public class Web_Dialog_Customer : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
BLL.b_Dialog_Customer bdc=new BLL.b_Dialog_Customer();
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!Page.IsPostBack)
{
this.DataGrid1.DataSource=bdc.c_Dialog_Customer(Page.Request.QueryString[sales],Page.Request.QueryString[desc] );
this.DataGrid1.DataBind();
} } #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.DataGrid1.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemDataBound);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.AlternatingItem | e.Item.ItemType==ListItemType.Item)
{
TextBox t_cust_name=(TextBox) e.Item.FindControl(txt_cust_name);
t_cust_name.Attributes.Add(onkeydown, if(event.keyCode==13) {var a=new Array( + e.Item.Cells[0].Text+ , +t_cust_name.ClientID+ .value ); window.opener=null;window.returnValue =a;window.close()});
}
}
}
}父窗口cs
private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e) { js=if(event.keyCode==13) ;
js+= {var desc= + dc.c_Chinese_CUST_NAME.ClientID + .value;;
js+=var sales='+ user+';;
js+=var nDialogWidth=700;var nDialogHeight=400;;
js+=var nLeft=(window.screen.availWidth-nDialogWidth)/2;;
js+=var nTop=(window.screen.availHeight-nDialogHeight)/2;;
js+=var sFeatures='dialogLeft:'+nLeft+'px;dialogTop:'+nTop+'px;dialogHeight:'+nDialogHeight+'px;dialogWidth:'+nDialogWidth+'px;help:no;status:no';;
js+=var bLogged=window.showModalDialog('Web_Dialog_Customer.aspx?type=1&desc='+escape(desc)+'&sales='+escape(sales),window,sFeatures);;
js+=if(bLogged != null);
js+= { + dc.c_Chinese_CUST_NAME.ClientID + .value=bLogged[1];;
js+= dc.cust_no.ClientID+.value=bLogged[0];;
js+= };
js+=};event.keyCode=9;;
dc.c_Chinese_CUST_NAME.Attributes.Add(onkeydown,js);
}
2.function GetText()
{
var objtxt = document.getElementById(Text_Uper);
opener.document.Form1.textBox_Uper.value=objtxt.value;
}