Session 传值问题

ljtlll 2009-01-30 09:04:30
我在girdview 上用js做了一个鼠标左击和右击事件,右击时打开一个页面,右击里打开另一个页面,可出现问题了,我点击后用JS打开的页面得不到Session["UserID"],用c#自己的函数打开的页面就能得到Session的值。以下是用JS打开而面的代码。各位大位救救小弟吧。
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{



string cellvalue = e.Row.Cells[6].Text;
string js = string.Format("window.open ('default.aspx?id=" +cellvalue + "') ");

e.Row.Attributes.Add("onclick", js);
string jss = "if(event.button == 2) window.open ('sale_edit.aspx?id=" + cellvalue + "')";

e.Row.Attributes.Add("onclick", js);
e.Row.Attributes.Add("onmousedown", jss);


//下面两句代码是添加鼠标效果,可以省略,当鼠标移动到行上时,变颜色
e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#FFC0FF'");
//当鼠标离开的时候 将背景颜色还原的以前的颜色
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");

}

}
...全文
102 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
宝_爸 2009-01-30
  • 打赏
  • 举报
回复
可以使用一个隐藏的label保存userid,然后在js中读取它。
宝_爸 2009-01-30
  • 打赏
  • 举报
回复
Js是运行在客户端,而session在服务器端,当然得不到了。

111,120

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧