后台里面建了一个首页,左边是用TreeView,而右边是用iframe框架做的。点击选项,右边出现对应的页面。。我首页已经用了session判断,但是如果我在其他页面用的话,不会整个页面都跳转到login.aspx,只是框架页面那部分跳转了。要怎样才能是跳转到完整的页面???try
{
if (Session["UserName"].ToString()== "")
{
Page.RegisterStartupScript("", "<script language='javascript' type='text/javascript'>location.href='../login.aspx';</script>");
}
}
catch (Exception ex)
{
}
{
if (Session["UserName"].ToString()== "")
{
Page.RegisterStartupScript("", "<script language='javascript' type='text/javascript'>location.href='../login.aspx';</script>");
}
}
catch (Exception ex)
{
}
{
private void ManagePage_Load(object sender, EventArgs e)
{
if(session["userid"]==null)
{
Response.Write("<script>alert(\"你没有登陆或登陆超时,该干嘛干嘛!\");</script>");
return;
}
}
}
{
protected void Page_Load(object sender, EventArgs e)
{
//try
//{
// if (Session["UserName"].ToString()== "")
// {
// Page.RegisterStartupScript("", "<script language='javascript' type='text/javascript'>location.href='../login.aspx';</script>");
// }
//}
//catch (Exception ex)
//{
//}
}
public class ManagePage : System.Web.UI.Page
{
private void ManagePage_Load(object sender, EventArgs e)
{
if (Session["UserName"].ToString() == "")
{
Page.RegisterStartupScript("", "<script language='javascript' type='text/javascript'>location.href='../login.aspx';</script>");
return;
}
}
}
public void PageExit()
{
Session["UserName"] = "";
Response.Write("../login.aspx");
}
}
public class ManagePage : System.Web.UI.Page
{
private void ManagePage_Load(object sender, EventArgs e)
{
if (Session["UserName"].ToString() == "")
{
Page.RegisterStartupScript("", "<script language='javascript' type='text/javascript'>location.href='../login.aspx';</script>");
return;
}
}
}其它页面的引用
public partial class BackGround_indext : ManagePage
{
protected void Page_Load(object sender, EventArgs e)
{你滴明白?
给你个例子: protected virtual void setFrameJS(){
string alertScript = "<script language=JavaScript>";
// alertScript += "\n" + "alert('window.top:' + window.top.location.href);";
// alertScript += "\n" + "alert('window.self:' + window.self.location.href);";
alertScript += "\n"+"if(window.top==window.self)";
alertScript += "\n"+"{";
alertScript += "\n"+"var temp=\"index.aspx?url=\"+window.self.location.href;";
// alertScript += "\n" + "alert('Temp:' + temp);";
alertScript += "\n"+"window.top.location.href=temp;";
alertScript += "\n"+"}";
alertScript += "</script" +">";
if (!ClientScript.IsClientScriptBlockRegistered("framejs"))
this.RegisterStartupScript("framejs", alertScript);
}
这是用js跳转技术 当你单独访问其他框架页面 自动给该页面加上框架
{
string scriptHtml = "<script language=JavaScript>";
scriptHtml += "\n" + "var temp=\"index.aspx\";";
scriptHtml += "\n" + "var tempUrl=window.self.location.href;";
scriptHtml += "\n" + "if(window.top==window.self)";
scriptHtml += "\n" + "{"; scriptHtml += "\n" + "if(tempUrl.indexOf(\"top.aspx\")>-1){";
scriptHtml += "\n" + "window.top.location.href=temp;";
scriptHtml += "\n" + "}"; scriptHtml += "\n" + "else if(tempUrl.indexOf(\"left.aspx\")>-1){";
scriptHtml += "\n" + "window.top.location.href=temp;";
scriptHtml += "\n" + "}"; scriptHtml += "\n" + "else{ temp=\"index.aspx?url=\"+window.self.location.href;";
scriptHtml += "\n" + "}";
scriptHtml += "\n" + "window.top.location.href=temp;";
scriptHtml += "\n" + "}";
scriptHtml += "</script" + ">";
if (!ClientScript.IsClientScriptBlockRegistered("framejs"))
this.RegisterStartupScript("framejs", scriptHtml);
}