我的登录框在主页面里.
gridview绑定了路径字段,但是未让它显示出来.
当点击gridview行之后,根据隐藏的路径字段的值再另外一个页面打开相应的DOC.
我需要的:
单击行之前,判断用户是否已经登录,如果已登录,则可以打开另外一个页面并显示该DOC.
如果用户未登录,则提示登录. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//判断当前行是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
string cellvalue = e.Row.Cells[4].Text;
string filepath1 = Server.MapPath("../DOC/");
string filepath = Path.Combine(filepath1, cellvalue);
e.Row.Attributes.Add("onclick", "window.open('ShowDoc.aspx?FilePath=" + Server.UrlEncode(filepath) + "')");
e.Row.Attributes["style"] = "Cursor:hand";
} }
gridview绑定了路径字段,但是未让它显示出来.
当点击gridview行之后,根据隐藏的路径字段的值再另外一个页面打开相应的DOC.
我需要的:
单击行之前,判断用户是否已经登录,如果已登录,则可以打开另外一个页面并显示该DOC.
如果用户未登录,则提示登录. protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
//判断当前行是否是数据行
if (e.Row.RowType == DataControlRowType.DataRow)
{
string cellvalue = e.Row.Cells[4].Text;
string filepath1 = Server.MapPath("../DOC/");
string filepath = Path.Combine(filepath1, cellvalue);
e.Row.Attributes.Add("onclick", "window.open('ShowDoc.aspx?FilePath=" + Server.UrlEncode(filepath) + "')");
e.Row.Attributes["style"] = "Cursor:hand";
} }
你的登录验证是用cookie?
如果是的话,写一个js函数判断。
如果是session判断,最好放在打开的页面里。
欢迎到我的论坛提问:http://bbs.0379zd.com
如果是session判断,最好放在打开的页面里?
我是用的Session,当点退出的时候需要清空Session.
请问清空Session的时候有需要注意的地方吗?
var arrStr = document.cookie.split("; ");
for(var i = 0;i < arrStr.length;i ++){
var temp = arrStr[i].split("=");
if(temp[0] == objName) return unescape(temp[1]);
}
}
function allCookie(){//读取所有保存的cookie字符串
var str = document.cookie;
if(str == ""){
str = "没有保存任何cookie";
}
alert(str);
}如果是sessionprotected void Page_Load(object sender, EventArgs e)
{
if (Session["users"] != null && Session["users"].ToString() != "")
{
}
else
{
返回登录;
}
}