日期:2014-05-17  浏览次数:20527 次

ASP.NET中怎么实现单击鼠标事件就可以完成父子窗口间传值问题
父子窗口各有一个TextBox控件和Button控件
其中farther.aspx中嵌入JS代码如下:
<script type ="text/javascript" language = "javascript">
  function OpenDlg() {
  window.open('son.aspx', 'newwindow', 'height=300,width=500,top=' + (screen.availHeight - 300) / 2 + ',left=' + (screen.availWidth - 300) / 2 + ',toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
  }
  </script>
farther.aspx.cs中代码如下:
protected void Page_Load(object sender, EventArgs e)
  {
  TextBox1.Text = Request.QueryString["id"];
  }
  protected void Button1_Click(object sender, EventArgs e)
  {
  this.Button1.Attributes.Add("onclick", "javascript:OpenDlg()");
  }
son.aspx.cs中代码如下:
  protected void Button1_Click(object sender, EventArgs e)
  {
  this.Button1.Attributes.Add("onclick", "javascript:opener.location.href='farther.aspx?id=" + TextBox2.Text + "';window.close();");
  }
为什么我需要双击Button才能实现打开新窗口(子窗口),在新窗口(子窗口)中也需要双击Button才能回到父窗口。
能不能只单击一次就可以打开新窗口,在新窗口中单击一次就能实现传值。跪求大牛们指点

------解决方案--------------------
function editDataSqlConfiOpen(url, width, height, title) {
top.dialog = new Macrowing.UI.WindowDialog({
width: width,
height: height,
title: title,
Fn: addAjaxTableDataRow,
isTop: true,
innerHTML: Macrowing.String.format("<iframe id='iframe1' src='{0}' frameborder='0' height='100%' width='100%'></iframe>", url)
});
top.dialog.showDialog();
return false;
}
function addAjaxTableDataRow() {
pageTablesCallBack(_pageArgs);
}
function pagerInit(pageArgs) {
if (document.ajaxProPager)
document.ajaxProPager.initialize(pageArgs, false);
else {
document.ajaxProPager = new Macrowing.UI.AjaxProPagerPilot(pageArgs, true);
document.ajaxProPager.pageChange = function (sender, args) {
pageArgs.CurrentPageIndex = document.ajaxProPager.currentPageIndex;
pageArgs.PageSize = document.ajaxProPager.pageSize;
pageTablesCallBack(pageArgs);
}
}
}
function pageTablesCallBack(args) {
var search = Macrowing.UI.AjaxPageForm.getPageFormControlValue("listSearch");
UltimusFlowConfigList.GetSearchFlowConfigList(search, args.CurrentPageIndex, args.PageSize, function (pageResult) {
var ajaxproTableArgs = { id: args.TableName, data: pageResult, isLoad: false, isSort: true, sortType: false };
if (document.ajaxProTable) {
ajaxproTableArgs.isLoad = true;
document.ajaxProTable.initialize(ajaxproTableArgs);
}
else {
document.ajaxProTable = new Macrowing.UI.AjaxProTable(ajaxproTableArgs);
document.ajaxProTable.dataSourceSort = function (sender, arg) { };
}
if (args.PagerName != null) {
args.ItemCount = pageResult.value.ItemCount;
args.ShowPageSize = 10;
args.Css = null;
args.Style = "color:blue;";
args.CurrentCss = null;
args.CurrentStyle = "color:red;";
pagerInit(args);
}
});
}
function pageArgs(size) {
_pageArgs.PageSize = size;
_pageArgs.CurrentPageIndex = 1;
_pageArgs.TableName = "listTable";
_pageArgs.PagerName = "listPager";
pageTablesCallBack(_pageArgs);
return false;
}
------解决方案----------------