asp.net 事件

来源:百度知道 编辑:UC知道 时间:2024/05/14 07:36:48
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{
username.Text = "在这里输入您的帐号";
dispinfo.Text = "";
}

protected void Button1_Click(object sender, EventArgs e)
{
if (username.Text == "在这里输入您的帐号" || username.Text == "")
{
dispinfo.Text = "用户帐号不能为空";
}else if (password.Text == "")
{
dispinfo.Text = "用户密码不能为空";
}
else {

1.为什么都是runat=server.却在cs中没有声明?

在page_load上面加:
protected System.Web.UI.WebControls.TextBox username;
protected System.Web.UI.WebControls.TextBox password;
protected System.Web.UI.WebControls.Button sub;
protected System.Web.UI.WebControls.Label dispinfo;

2.判断字符串的时候一般不用 == .而用Equals();
如:username.Text.Equals("在这里输入您的帐号");