我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

asp.net登陆前台后台源代码

 前台代码:

创新互联是一家专业提供永吉企业网站建设,专注与成都网站建设、网站制作、html5、小程序制作等业务。10年已为永吉众多企业、政府机构等服务。创新互联专业网站建设公司优惠进行中。


    
     
        body {font:12px Helvetica, Arial, sans-serif;  margin:100px auto; padding:0; word-wrap:break-word; word-break:break-all; background-color:#016BA9;}
        .login1{background-p_w_picpath: url(../Images/login_1.jpg); width:960px; height:94px; margin:0 auto;}
        .login2{background-p_w_picpath: url(../Images/login_2.jpg); width:960px; height:49px; margin:0 auto; }
        .login3{background-p_w_picpath: url(../Images/login_3.jpg); width:960px; height:125px; margin:0 auto;}
        .login4{background-p_w_picpath: url(../Images/login_4.jpg); width:960px; height:91px; margin:0 auto;}
        .loginTXT{border: 1px solid #800000; width:150px; background-color:#866961; color:#fff; height:19px;}
    
      
          if (top.location != self.location)
              top.location = self.location; 

          function CheckIn() {
              var names = document.getElementById("txtU_Name").value;
              var pass = document.getElementById("txtU_Pass").value;
              var check = document.getElementById("txtU_Check").value;
              if (names == "") {
                  alert("请输入用户名...");
                  document.getElementById("txtU_Name").focus();
                  return false;
              }
              else if (pass == "") {
                  alert("请输入用户密码...");
                  document.getElementById("txtU_Pass").focus();
                  return false;
              }
              else if (check == "") {
                  alert("请输入验证码...");
                  document.getElementById("txtU_Check").focus();
                  return false;
              }
          }
    



    


    

    
           
    
        用户名称:
         
    
    
        用户密码:
         
    
    
        验证代码:
         
    
    
        
    
    
        
        
            
                              onclick="BtnHome_Click" />
        
    
   
    

    
    

 

 

 

 

 

后台代码:

 

 

 protected void BtnLogin_Click(object sender, EventArgs e)
    {
        string username = txtU_Name.Text;
        string pwd = txtU_Pass.Value;
        string check = txtU_Check.Text;

        if (CheckNull())
        {
            if (check.ToString().ToLower() == Session["ValidateCode"].ToString().ToLower())
            {
                string strsql = "select count(1) from Login where UserName='" + username + "' and UserPwd='" + pwd + "'";
                object obj = SqlHelper.ExecuteScalar(ConfigurationManager.ConnectionStrings["conn"].ToString(), CommandType.Text, strsql);
                if (obj != null && (int)obj > 0)
                {
                    Response.Write("");
                    Session["username"] = username;

                    HttpCookie hc = new HttpCookie("username", username);
                    hc.Expires = DateTime.Now.AddMinutes(1);
                    Response.Cookies.Add(hc);

                    Response.Redirect("Main.aspx");
                }
                else
                {
                    Response.Write("");
                    Response.Write("");
                }
            }
            else
            {
                Response.Write("");
                Response.Write("");

            }
        }


    }
    private bool CheckNull()
    {
        return (!(string.IsNullOrEmpty(txtU_Name.Text.Trim())) && !(string.IsNullOrEmpty(txtU_Pass.Value.Trim())) && !(string.IsNullOrEmpty(txtU_Check.Text.Trim()))) ? true : false;
    }

 

main主页代码:page_Load

 try
        {
            string username = Session["username"].ToString();
        }
        catch
        {
            Response.Write("");
        }

 

 


当前文章:asp.net登陆前台后台源代码
链接分享:http://mswzjz.cn/article/jsisdc.html

其他资讯