日期:2014-05-19  浏览次数:20402 次

如何让ASP.NET登录时区分大小写?
我的用户名不分大小写。大小写都可以成功登录。数据库用的是SQL   Server   2000的。里面的内容都是区

分大小写的。直接打开数据库,或是用Gridview和自己写的代码在textbox里显示都是区分大小写。真不

明白为什么登录时却大小不分。

这是MyClass的代码,放在MyClass.cs里面。以后调用。
--------------------------------------

using   System;

namespace   WebApplication
{
///   <summary>
///   MyClass   的摘要说明。
///   </summary>
public   class   MyClass
{
public   MyClass()
{
//
//   TODO:   在此处添加构造函数逻辑
//
}
private   static   string  

connString= "Server=localhost;uid=sa;pwd=;database=webdevelop ";

public   static   string   ConnString
{
get
{
return   connString;
}
}
}
}


--------------------------------------

这是登录按钮的代码。

--------------------------------------
using   System;
using   System.Collections;
using   System.ComponentModel;
using   System.Data;
using   System.Drawing;
using   System.Web;
using   System.Web.SessionState;
using   System.Web.UI;
using   System.Web.UI.WebControls;
using   System.Web.UI.HtmlControls;
using   System.Data.SqlClient;

namespace   WebApplication
{
///   <summary>
///   Main   的摘要说明。
///   </summary>
public   class   Main   :   System.Web.UI.Page
{
protected   System.Web.UI.WebControls.HyperLink   HyperLinkSearch;
protected   System.Web.UI.WebControls.HyperLink   HyperLinkForum;
protected   System.Web.UI.WebControls.HyperLink   HyperLinkExplorer;
protected   System.Web.UI.WebControls.TextBox   TextBoxName;
protected   System.Web.UI.WebControls.TextBox   TextBoxPassword;
protected   System.Web.UI.WebControls.Button   ButtonEnter;
protected   System.Web.UI.WebControls.Button   ButtonLogin;
protected   System.Web.UI.WebControls.TextBox   TextBoxState;

private   void   Page_Load(object   sender,   System.EventArgs   e)
{
//   在此处放置用户代码以初始化页面
if(!Page.IsPostBack)
{
if(Session[ "userName "].ToString()!= " ")
{
this.TextBoxState.Text= "用户 "+Session

[ "userName "].ToString()+ "登录成功。 ";
SetEnable(true);
}
else
{
this.TextBoxState.Text= "如果你已经注册过,请登录,如

果尚未注册,请先注册! ";
SetEnable(false);
}
}

}

#region   Web   窗体设计器生成的代码
override   protected   void   OnInit(EventArgs   e)
{
//
//   CODEGEN:   该调用是   ASP.NET   Web   窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

///   <summary>
///   设计器支持所需的方法   -   不要使用代码编辑器修改
///   此方法的内容。
///   </summary>
private   void   InitializeComponent()
{        
this.ButtonEnter.Click   +=   new   System.EventHandler

(this.ButtonEnter_Click);
this.ButtonLogin.Click   +=   new   System.EventHandler

(this.ButtonLogin_Click);