项目结束后留下的未用上的知识点

时间:2022-07-28 08:54:49

<Columns>
     <asp:HyperLinkField Text="明细" Target="_blank" DataNavigateUrlFormatString="KeHuDetail.ASPX?ID={0}" DataNavigateUrlFields="ID" />
</Columns>


 

 

protected void GridView1_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
{
    //这种方法会被浏览器警告,不实用。

    Response.Write("<script>window.open('KeHuWangLaiJiLuDetail.ASPX?ID="+GridView1.Rows[e.NewSelectedIndex].Cells[1].Text.Trim()+"','_blank');</script>");
 
    //Response.Redirect("KeHuWangLaiJiLuDetail.ASPX?ID="+GridView1.Rows[e.NewSelectedIndex].Cells[1].Text.Trim());
}
    

 

//登录之后将菜单项从登录改成注销

protected void Menu1_MenuItemDataBound(object sender, MenuEventArgs e)
{
    if (e.Item.Text == "登录")
    {
        var p=Roles.GetRolesForUser().Count();

        if (p > 0)
        {
            e.Item.Text = "注销";
            e.Item.NavigateUrl = "~/Logout.ASPX";
         }
    }
}

 

//Logout.ASPX

 protected void Page_Load(object sender, EventArgs e)
 {
    if (!IsPostBack)
    {
        Session.Clear(); 
        Session.Abandon();
        FormsAuthentication.SignOut();
        Response.Redirect("~/Login.ASPX");
    }
}