页面跳转 想用一个控件(或者是表格)显示一条数据,当双击控件(或表格)时可以用弹出的方式跳转到一个新的页面,在跳转的时候需要传递参数。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 神马问题啊,不会google啊随便给你贴一个。。不自己写了。///后台在数据绑定时注册一个JavaScript方法///////////protected void gvDraft_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onclick", "return openLink('" + url + "')"); } }////////前台增加一个相应的JS方法//////////////function openLink(url) { window.open("MonthTargetAdjust.aspx?" + url, "1", "resizable=yes,toolbar=no,statusbar=no,menubar=no,location=no,scrollbars=yes,titlebar=no,width:900,height:700"); } 注册属性。.Attributes["OnClick"]= "window.location.href=URL?参数Id=传递值"; RowDataBound里e.Row.Attributes.Add("onDblClick", "javascript:window.opener.location.href='子窗体B.aspx?id="+e.Row.Cells[1].Text.ToString() + "';window.close();"); e.Row.Attributes.Add("onDblClick", "javascript:window.opener.documentById('txt').value='"+e.Row.Cells[1].Text.ToString() + "';window.close();"); aspx页面<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Demo1</title></head><body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound"> </asp:GridView> </div> </form></body></html>后台代码:public partial class Demo1 : System.Web.UI.Page { public class Employee { public string EmpID { set; get; } public string EmpName { set; get; } } protected void Page_Load(object sender, EventArgs e) { this.GridView1.DataSource = new System.Collections.Generic.List<Employee>() { new Employee(){ EmpID="S001", EmpName="张三"}, new Employee(){ EmpID="S002", EmpName="李四"}, new Employee(){ EmpID="S003", EmpName="王五"}, new Employee(){ EmpID="S004", EmpName="赵六"}, new Employee(){ EmpID="S005", EmpName="小七"} }; this.GridView1.DataBind(); } protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("ondblclick", "window.open('DetailView.aspx?EmpID=" + DataBinder.Eval(e.Row.DataItem, "EmpID") + "');"); } } }DetailView.aspx.cs获取EmpID/// <summary> /// 员工编号 /// </summary> public string EmpID { get { return Request.QueryString["EmpID"] ?? string.Empty; } } C# 如何将图片读到内存在显示 在客户端如何用JS获取abc.aspx.cs中定义的Session["OK"]的值? 关于2.0 TreeView的客户端事件及获取Value值的问题. 新人求帮助~ 如何提升权限?我只记得有人说过改machine.config里的什么东西,但是我忘了 关于asp.Net中怎么样输出标准的Word文档 大家帮看看这代码怎么写 DataRow 网页内嵌暴风影音播放器,暴风影音中的activex插件还有吗 c#中如何判断一个变量为日期型? 如何在两个页面之间传递信息 怎么实现排序? 分享一个好用的n级联动下拉列表框(有源码、有省市区县数据库)
protected void gvDraft_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("onclick", "return openLink('" + url + "')");
}
}
////////前台增加一个相应的JS方法//////////////
function openLink(url) {
window.open("MonthTargetAdjust.aspx?" + url, "1", "resizable=yes,toolbar=no,statusbar=no,menubar=no,location=no,scrollbars=yes,titlebar=no,width:900,height:700");
}
e.Row.Attributes.Add("onDblClick", "javascript:window.opener.location.href='子窗体B.aspx?id="+e.Row.Cells[1].Text.ToString() + "';window.close();");
e.Row.Attributes.Add("onDblClick", "javascript:window.opener.documentById('txt').value='"+e.Row.Cells[1].Text.ToString() + "';window.close();");
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Demo1</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" OnRowDataBound="GridView1_RowDataBound">
</asp:GridView>
</div>
</form>
</body>
</html>后台代码:
public partial class Demo1 : System.Web.UI.Page
{
public class Employee
{
public string EmpID { set; get; }
public string EmpName { set; get; }
} protected void Page_Load(object sender, EventArgs e)
{
this.GridView1.DataSource = new System.Collections.Generic.List<Employee>()
{
new Employee(){ EmpID="S001", EmpName="张三"},
new Employee(){ EmpID="S002", EmpName="李四"},
new Employee(){ EmpID="S003", EmpName="王五"},
new Employee(){ EmpID="S004", EmpName="赵六"},
new Employee(){ EmpID="S005", EmpName="小七"}
};
this.GridView1.DataBind();
} protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add("ondblclick", "window.open('DetailView.aspx?EmpID=" + DataBinder.Eval(e.Row.DataItem, "EmpID") + "');");
}
}
}DetailView.aspx.cs获取EmpID
/// <summary>
/// 员工编号
/// </summary>
public string EmpID
{
get { return Request.QueryString["EmpID"] ?? string.Empty; }
}