用javascript怎样在一个页面中访问另一个页面控件的属性 怎样在caigou.aspx中单击按钮“提交”时能够使页面RunCenter.aspx中的datagrid中的一个按钮列,由文本值为“审核”改为“已审核”单击“提交“时会该动数据库中的”定单表“中的”数量“这一字段的值。希望知道的高手们能够给我回答,我在一个项目开发中急需用。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <%@ Page language="c#" Codebehind="RunCenter.aspx.cs" AutoEventWireup="false" Inherits="bsTest2005_8_16.CSDN.RunCenter" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><HTML> <HEAD> <title>RunCenter</title> <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" Content="C#"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False"> <Columns> <asp:TemplateColumn> <ItemTemplate> <asp:HyperLink id="HyperLink1" runat="server" Target="_blank" NavigateUrl="caigou.aspx">HyperLink</asp:HyperLink> </ItemTemplate> </asp:TemplateColumn> <asp:BoundColumn DataField="id"></asp:BoundColumn> <asp:BoundColumn DataField="subject"></asp:BoundColumn> <asp:BoundColumn DataField="Re"></asp:BoundColumn> <asp:BoundColumn DataField="status"></asp:BoundColumn> <asp:TemplateColumn> <ItemTemplate> <asp:Button id="Button1" runat="server" CommandName="MyCommand" Text="审核"></asp:Button> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> </form> </body></HTML>==================================public class RunCenter : System.Web.UI.Page { protected System.Web.UI.WebControls.DataGrid DataGrid1; private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if(!IsPostBack) { BindTestData(); } } private void BindTestData() { DataTable dt = new DataTable(); dt.Columns.Add("ID"); dt.Columns.Add("subject"); dt.Columns.Add("Re"); dt.Columns.Add("status"); dt.Rows.Add(new object[]{1,"aaa asd a aw a sd f","AAA",1}); dt.Rows.Add(new object[]{2,"bbb asd fa aw3f aw3g ","BBB",1}); dt.Rows.Add(new object[]{3,"cccawegawegawe","CCC",5}); dt.Rows.Add(new object[]{4,"dddawefwega awe","DDD",null}); dt.Rows.Add(new object[]{5,"eeeawefwe awef","eee",3}); dt.AcceptChanges(); this.DataGrid1.DataSource = dt; 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.ItemIndex>-1) { DataRowView row = (DataRowView)e.Item.DataItem; HyperLink hl = (HyperLink)e.Item.FindControl("HyperLink1"); Button lbtn = (Button)e.Item.FindControl("Button1"); hl.NavigateUrl += "?id=" + row["id"].ToString() + "&refControl=" + lbtn.ClientID; } } } <%@ Page language="c#" Codebehind="caigou.aspx.cs" AutoEventWireup="false" Inherits="bsTest2005_8_16.CSDN.caigou" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ><HTML> <HEAD> <title>caigou</title> <meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" Content="C#"> <meta name="vs_defaultClientScript" content="JavaScript"> <meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5"> </HEAD> <body MS_POSITIONING="GridLayout"> <form id="Form1" method="post" runat="server"> <asp:Button id="Button1" runat="server" Text="提交"></asp:Button> </form> </body></HTML>=============================================public class caigou : System.Web.UI.Page { protected System.Web.UI.WebControls.Button Button1; private void Page_Load(object sender, System.EventArgs e) { // 在此处放置用户代码以初始化页面 if(!IsPostBack) { string id = Request.QueryString["id"]; string refcontrol = Request.QueryString["refControl"]; } } #region Web 窗体设计器生成的代码 override protected void OnInit(EventArgs e) { // // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。 // InitializeComponent(); base.OnInit(e); } /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.Button1.Click += new System.EventHandler(this.Button1_Click); this.Load += new System.EventHandler(this.Page_Load); } #endregion private void Button1_Click(object sender, System.EventArgs e) { string id = Request.QueryString["id"]; string refcontrol = Request.QueryString["refControl"]; //此处添加执行数据库更新的操作 Response.Write("<script>opener.document.getElementById('"+refcontrol+"').value='已审核';window.close();</script>"); } } javascript的窗口间调用总结有以下几个:parent,opener,top父窗体可以累计 单击hyperlink时也激发datagrid_itemdatabind()事件,返回的也是RunCenter.aspx页面这是怎么回事呀? 过滤敏感词组 為什么在asp.net的aspx頁面上面的div無法响应鼠标事件? 100分求三级联动 Button1_Click事件Textbox取不到三个联动的text和value 顶都给分!~~~用户控件,页面的数值传递出错 如何隐藏用户控件! DataGrid 中的Edit事件 验证控件中如何判断text为空,且长度在0-20间? Table1.Rows的排序问题 很有挑战性的一个问题:关于.net与IIS的配合认证 关于Asp.Net验证的设置问题!!! 问个简单的问题 asp.net 按输入内容进行模糊查询
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>RunCenter</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:DataGrid id="DataGrid1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:HyperLink id="HyperLink1" runat="server" Target="_blank" NavigateUrl="caigou.aspx">HyperLink</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="id"></asp:BoundColumn>
<asp:BoundColumn DataField="subject"></asp:BoundColumn>
<asp:BoundColumn DataField="Re"></asp:BoundColumn>
<asp:BoundColumn DataField="status"></asp:BoundColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:Button id="Button1" runat="server" CommandName="MyCommand" Text="审核"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:DataGrid>
</form>
</body>
</HTML>
==================================
public class RunCenter : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DataGrid1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
{
BindTestData();
}
} private void BindTestData()
{
DataTable dt = new DataTable();
dt.Columns.Add("ID");
dt.Columns.Add("subject");
dt.Columns.Add("Re");
dt.Columns.Add("status");
dt.Rows.Add(new object[]{1,"aaa asd a aw a sd f","AAA",1});
dt.Rows.Add(new object[]{2,"bbb asd fa aw3f aw3g ","BBB",1});
dt.Rows.Add(new object[]{3,"cccawegawegawe","CCC",5});
dt.Rows.Add(new object[]{4,"dddawefwega awe","DDD",null});
dt.Rows.Add(new object[]{5,"eeeawefwe awef","eee",3});
dt.AcceptChanges(); this.DataGrid1.DataSource = dt;
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.ItemIndex>-1)
{
DataRowView row = (DataRowView)e.Item.DataItem;
HyperLink hl = (HyperLink)e.Item.FindControl("HyperLink1");
Button lbtn = (Button)e.Item.FindControl("Button1");
hl.NavigateUrl += "?id=" + row["id"].ToString() + "&refControl=" + lbtn.ClientID;
}
}
}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>caigou</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" runat="server" Text="提交"></asp:Button>
</form>
</body>
</HTML>
=============================================
public class caigou : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)
{
string id = Request.QueryString["id"];
string refcontrol = Request.QueryString["refControl"];
}
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
string id = Request.QueryString["id"];
string refcontrol = Request.QueryString["refControl"]; //此处添加执行数据库更新的操作 Response.Write("<script>opener.document.getElementById('"+refcontrol+"').value='已审核';window.close();</script>"); }
}
parent,opener,top
父窗体可以累计
这是怎么回事呀?