一个关于ASP。NET的简单问题
题目是这样的:创建一个名为LOGIN的登陆程序,放三个LABEL和两个TEXTBOX,一个BUTTON,三个LABEL分别是题目,用户,密码。TEXTBOX则分别接受用户名和密码,要求使用REQUEST对象获取用户名和密码,验证用户输入的密码是否为“*****”,是的话则使用RESPONSE对象显示信息“用户名,你的登陆信息正确”,不是的话则显示“用户名,你的登陆信息不正确”。请问这是不是要写判断语句,为什么我象下面这样写,运行的时候会报错。正确的写法应该是怎么写?多谢多谢。
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.IO;
namespace WebApplication1
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.TextBox UserName;
protected System.Web.UI.WebControls.TextBox Password;
protected System.Web.UI.WebControls.Label Label3;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.UserName.TextChanged += new System.EventHandler(this.TextBox1_TextChanged);
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void TextBox1_TextChanged(object sender, System.EventArgs e)
{
}
private void Button1_Click(object sender, System.EventArgs e)
{
//定义两个变量,获取从文本框输入的字符
String s1,s2;
s1=(Request.Form.Get(UserName);
s2=Request.Form.Get(Password);
if(s2!="*****")
//如果我要获取从文本框中输入的字符,并复给一个变量应该怎么做,这样做不行,运行的时候报错
Response.Write("s1,+您的登陆信息不正确");
else
Response.Write("s1,+您的登陆信息正确");
}
}
}