http://www.chinabs.net/aspnet/default.asp?infoid=40

解决方案 »

  1.   

    用服务端验证方式
    做个asp:Button,写click事件,取得你的用户,密码,构造sql语句验证
    错的话出个提示,对的话,转到登录后的页面
      

  2.   

    //可以用用看public String Login(string workId,string password)
    {
      SqlConnection myConnection = new SqlConnection (ConfigurationSettings.AppSettings["ConnectionString"]) ;
      SqlCommand myCommand = new SqlCommand ("Aspx_UserLogin",myConnection) ;
      myCommand.CommandType = CommandType.StoredProcedure ;
      //Add WorkId ;
      SqlParameter paramWorkId = new SqlParameter ("@WorkId",SqlDbType.NVarChar,10) ;
      paramWorkId.Value = workId ;
      myCommand.Parameters.Add(paramWorkId) ;
      //Add Password ;
      SqlParameter paramPassword = new SqlParameter ("@Password",SqlDbType.NVarChar,10) ;
      paramPassword.Value = password ;
      myCommand.Parameters.Add(paramPassword) ;
      //Add UserId ;
      SqlParameter paramUserId = new SqlParameter ("@UserId",SqlDbType.Int,4) ;
      paramUserId.Direction = ParameterDirection.Output ;
      myCommand.Parameters.Add(paramUserId) ;
      //Open the Connection and Execute the Command ;
      myConnection.Open() ;
      myCommand.ExecuteNonQuery() ;
      myConnection.Close() ;
      
      int UserId = (int) (paramUserId.Value) ;
      if (UserId == 0)
        return null ;
      else
        return UserId.ToString() ;
    }
    //==============================
    void Page_Load(Object sender,EventArgs e)
      { 
        if(Request.Form["workId"]!= null)

      Air.UserDB UserSystem = new Air.UserDB() ;
      string UserId = UserSystem.Login(Request.Form["workId"],Request.Form["password"]) ;
      if (UserId == null)
      { 
        string scriptStr = "<script>alert('用户名或者密码有错误,请重新登陆!')<" ;
               scriptStr += "/" ;
       scriptStr += "script>" ;
        Response.Write(scriptStr) ;
      }
      else
      {
        Air.UserDetails userDetails = UserSystem.GetUserDetails(UserId) ;
        Response.Redirect("Main.aspx");
      }
         

      }