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

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

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

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

首先新寫一個(gè)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頁(yè)面后臺(tái)部分代碼

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('用戶名或密碼錯(cuò)誤!')</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('用戶名或密碼錯(cuò)誤!')</script>");
        }
      }

以stuWishChoices頁(yè)面為例,繼承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)
      {
    
      }

    }
  }
}

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

相關(guān)文章

最新評(píng)論

进贤县| 周至县| 金塔县| 陕西省| 云和县| 林周县| 舒兰市| 铜川市| 卓尼县| 砀山县| 襄樊市| 汕尾市| 沐川县| 融水| 阿拉善右旗| 军事| 星座| 西乌| 宣化县| 抚顺县| 福州市| 南通市| 邵武市| 冀州市| 磴口县| 黔西| 临夏县| 上犹县| 南昌市| 阿克苏市| 东城区| 张北县| 长泰县| 祁连县| 焦作市| 曲沃县| 衡山县| 庄河市| 诸城市| 彰化县| 沐川县|