最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

.net后臺頁面統(tǒng)一驗(yàn)證是否登錄

 更新時間:2017年04月25日 09:35:46   作者:真果粒  
這篇文章主要為大家詳細(xì)介紹了.net后臺頁面統(tǒng)一驗(yàn)證是否登錄的方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了.net后臺頁面統(tǒng)一驗(yàn)證是否登錄的具體代碼,供大家參考,具體內(nèi)容如下

首先新寫一個PageBase類

using System;
using System.Collections.Generic;
using System.Web;

namespace DepartmentMIS.Web.myclass
{
  public class PageBase : System.Web.UI.Page
  {
    public PageBase()
    {
      this.Load += new EventHandler(BasePage_Load);
    }

    private void BasePage_Load(object sender, EventArgs e)
    {
      if (Session["UserNo"] == null || Session["UserNo"].ToString() == "")
      {
        Response.Redirect("~/Login.aspx");
      }
    }
  }
}

Login頁面后臺部分代碼

protected void btnLogin_Click(object sender, EventArgs e)
    {
      if (rblRole.SelectedValue == "1")
      {
        DataSet ds = AdminBLL.GetList("userName = '" + tbxUserName.Text.Trim() + "' and password = '" + tbxPassword.Text.Trim()+"' and isDeleted = 0");
        if (ds.Tables[0].Rows.Count == 1)
        {
          int id = Convert.ToInt32(ds.Tables[0].Rows[0]["id"]);
          Session["UserNo"] = ds.Tables[0].Rows[0]["id"];
          Session["UserName"] = ds.Tables[0].Rows[0]["userName"];
          Response.Redirect("admin/adminIndex.aspx");
        }
        else
        {
          Response.Write("<script>alert('用戶名或密碼錯誤!')</script>");
        }
      }
      if (rblRole.SelectedValue == "2")
      {
        DataSet ds = StuBLL.GetList("stuNo = '" + tbxUserName.Text.Trim() + "' and password = '" + tbxPassword.Text.Trim() + "' and isDeleted = 0");
        if (ds.Tables[0].Rows.Count == 1)
        {
          int id = Convert.ToInt32(ds.Tables[0].Rows[0]["id"]);
          Session["UserNo"] = ds.Tables[0].Rows[0]["id"];
          Session["UserName"] = ds.Tables[0].Rows[0]["stuName"];
          Response.Redirect("student/stusIndex.aspx");
        }
        else
        {
          Response.Write("<script>alert('用戶名或密碼錯誤!')</script>");
        }
      }

以stuWishChoices頁面為例,繼承PageBase類

using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.Collections;

namespace cbmis.ProDocumentMng
{
  public partial class DocumentList : BasePage //繼承
  {
      protected void Page_Load(object sender, EventArgs e)
      {
    
      }

    }
  }
}

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

凤翔县| 清镇市| 凤翔县| 建瓯市| 贡嘎县| 河曲县| 通州区| 景宁| 天祝| 贵州省| 汶川县| 始兴县| 兴和县| 临泽县| 濮阳市| 泌阳县| 定安县| 聂拉木县| 马关县| 凌源市| 桦川县| 台东市| 称多县| 宜阳县| 万全县| 长兴县| 旌德县| 边坝县| 略阳县| 奎屯市| 鸡泽县| 万年县| 乐都县| 满洲里市| 岚皋县| 谷城县| 彩票| 秦安县| 绵竹市| 雷州市| 赤峰市|