asp.net中运算符“==”无法应用于“方法组”和“string”类型的操作数
protectedvoidButton1_Click(objectsender,EventArgse){if(TextBox1.Text.Trim()==""||Text...
protected void Button1_Click(object sender, EventArgs e)
{
if (TextBox1.Text.Trim() == "" || TextBox2.Text.Trim == "")
{
if (TextBox1.Text.Trim() == "" && TextBox2.Text.Trim() == "")
Response.Write("<script>alert(\"用户名和密码不能为空!\");</script>");
else if (TextBox1.Text.Trim() == "")
Response.Write("<script>alert(\"用户名不能为空!\");</script>");
else if (TextBox2.Text.Trim() == "")
Response.Write("<script>alert(\"密码不能为空!\");</script>");
}
else
{
int count = 0;
if (DropDownList1.SelectedValue == "学生")
{
int exist;
exist=(new projclass()).ifstuexist(TextBox1.Text);
if (exist == 1)
{
count = (new projclass()).getstu(TextBox1.Text,TextBox2.Text);
if (count == 1)
{
string 学号 = TextBox1.Text.ToString();
Session["学号"] = 学号;
Response.Redirect("student.aspx");
}
else Response.Write("<script>alert(\"密码错误!请重新输入\");</script>");
}
else Response.Write("<script>alert(\"学号不存在!请确认学号输入正确\");</script>");
} 展开
{
if (TextBox1.Text.Trim() == "" || TextBox2.Text.Trim == "")
{
if (TextBox1.Text.Trim() == "" && TextBox2.Text.Trim() == "")
Response.Write("<script>alert(\"用户名和密码不能为空!\");</script>");
else if (TextBox1.Text.Trim() == "")
Response.Write("<script>alert(\"用户名不能为空!\");</script>");
else if (TextBox2.Text.Trim() == "")
Response.Write("<script>alert(\"密码不能为空!\");</script>");
}
else
{
int count = 0;
if (DropDownList1.SelectedValue == "学生")
{
int exist;
exist=(new projclass()).ifstuexist(TextBox1.Text);
if (exist == 1)
{
count = (new projclass()).getstu(TextBox1.Text,TextBox2.Text);
if (count == 1)
{
string 学号 = TextBox1.Text.ToString();
Session["学号"] = 学号;
Response.Redirect("student.aspx");
}
else Response.Write("<script>alert(\"密码错误!请重新输入\");</script>");
}
else Response.Write("<script>alert(\"学号不存在!请确认学号输入正确\");</script>");
} 展开
2个回答
展开全部
这句代码 if (TextBox1.Text.Trim() == "" || TextBox2.Text.Trim == "")
改为if (TextBox1.Text.Trim() == "" || TextBox2.Text.Trim() == "")
后面的trim方法少了个括号
改为if (TextBox1.Text.Trim() == "" || TextBox2.Text.Trim() == "")
后面的trim方法少了个括号
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询