父窗口的超链接:
<a href="#" οnclick="getProductType('tb_category');">选择分类</a>
tb_category:为要接受子窗口参数的父窗口textbox
< script language = " javascript " type = " text/javascript " >
function getProductType(c)
{
var win;
var sWidth = screen.availWidth;
var sHeight = screen.availHeight;
var l = sWidth / 2 - 400;
var t = sHeight / 2 - 556;
win =window.open("B2C_Orders_NewOrderProductList.aspx?sourceC=" + c,"B2C_Orders_NewOrderProductList","height=400, width=556, top=" + t + ", left=" + l + ", toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no");
win.focus();
}
</ script >
子窗口aspx代码:
父窗口cs代码:
<a href="#" οnclick="getProductType('tb_category');">选择分类</a>
tb_category:为要接受子窗口参数的父窗口textbox
< script language = " javascript " type = " text/javascript " >
function getProductType(c)
{
var win;
var sWidth = screen.availWidth;
var sHeight = screen.availHeight;
var l = sWidth / 2 - 400;
var t = sHeight / 2 - 556;
win =window.open("B2C_Orders_NewOrderProductList.aspx?sourceC=" + c,"B2C_Orders_NewOrderProductList","height=400, width=556, top=" + t + ", left=" + l + ", toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, status=no");
win.focus();
}
</ script >
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="B2C_Orders_NewOrderProductList.aspx.cs" Inherits="system_B2C_Orders_NewOrderProductList"
%>
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head runat ="server" >
< title > 商品分类选择 </ title >
< link href ="css/sub.css" rel ="stylesheet" type ="text/css" />
< script language ="javascript" type ="text/javascript" >
function returnResult(v,c)
{
var openerC = opener.document.getElementById(c);
//var openerC = window.opener.docInforFrame.document.getElementById(c);
if(openerC != null)
{
openerC.value = v;
}
else
{
openerC.value = "分类提取失败!";
}
window.close();
}
</ script >
</ head >
< body >
< form id ="form1" runat ="server" >
< asp:TreeView ID ="trv_categoryTree" runat ="server" ImageSet ="WindowsHelp" >
< ParentNodeStyle Font-Bold ="False" />
< HoverNodeStyle Font-Underline ="True" ForeColor ="#6666AA" />
< SelectedNodeStyle BackColor ="#B5B5B5" Font-Underline ="False" HorizontalPadding ="0px"
VerticalPadding ="0px" />
< NodeStyle Font-Names ="Tahoma" Font-Size ="8pt" ForeColor ="Black" HorizontalPadding ="5px"
NodeSpacing ="0px" VerticalPadding ="1px" />
</ asp:TreeView >
</ form >
</ body >
</ html >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head runat ="server" >
< title > 商品分类选择 </ title >
< link href ="css/sub.css" rel ="stylesheet" type ="text/css" />
< script language ="javascript" type ="text/javascript" >
function returnResult(v,c)
{
var openerC = opener.document.getElementById(c);
//var openerC = window.opener.docInforFrame.document.getElementById(c);
if(openerC != null)
{
openerC.value = v;
}
else
{
openerC.value = "分类提取失败!";
}
window.close();
}
</ script >
</ head >
< body >
< form id ="form1" runat ="server" >
< asp:TreeView ID ="trv_categoryTree" runat ="server" ImageSet ="WindowsHelp" >
< ParentNodeStyle Font-Bold ="False" />
< HoverNodeStyle Font-Underline ="True" ForeColor ="#6666AA" />
< SelectedNodeStyle BackColor ="#B5B5B5" Font-Underline ="False" HorizontalPadding ="0px"
VerticalPadding ="0px" />
< NodeStyle Font-Names ="Tahoma" Font-Size ="8pt" ForeColor ="Black" HorizontalPadding ="5px"
NodeSpacing ="0px" VerticalPadding ="1px" />
</ asp:TreeView >
</ form >
</ body >
</ html >
using
System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class system_B2C_Orders_NewOrderProductList : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Request.QueryString["sourceC"] != null)
{
Session["SE_system_B2C_Orders_NewOrderProductList"] = Request.QueryString["sourceC"].Trim();
}
if (Request.QueryString["CatId"] == null)
{
B2C_CategoryTree categoryTree = new B2C_CategoryTree();
//生成树
categoryTree.GetMerchCatTreeForType(this.trv_categoryTree, sql_b2c.sql305, "B2C_Orders_NewOrderProductList.aspx", Server);
}
else
{
//returnResult
ScriptManager.RegisterStartupScript(Page, typeof(system_B2C_Orders_NewOrderProductList), "", "returnResult('" + Request.QueryString["CatId"].Trim() + "','" + Session["SE_system_B2C_Orders_NewOrderProductList"].ToString().Trim() + "');", true);
}
}
}
}
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class system_B2C_Orders_NewOrderProductList : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Request.QueryString["sourceC"] != null)
{
Session["SE_system_B2C_Orders_NewOrderProductList"] = Request.QueryString["sourceC"].Trim();
}
if (Request.QueryString["CatId"] == null)
{
B2C_CategoryTree categoryTree = new B2C_CategoryTree();
//生成树
categoryTree.GetMerchCatTreeForType(this.trv_categoryTree, sql_b2c.sql305, "B2C_Orders_NewOrderProductList.aspx", Server);
}
else
{
//returnResult
ScriptManager.RegisterStartupScript(Page, typeof(system_B2C_Orders_NewOrderProductList), "", "returnResult('" + Request.QueryString["CatId"].Trim() + "','" + Session["SE_system_B2C_Orders_NewOrderProductList"].ToString().Trim() + "');", true);
}
}
}
}