我已經使用c#和web服務創建了一個聯繫表單。如果用戶未填寫姓名或姓名是數字,我希望收到警告消息。這是我的C#代碼:如何糾正我的空例外?
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Validation.WebService validate = new Validation.WebService();
bool ismail = validate.isEmail(TextBox2.Text);
if (!ismail)
{ Label1.Text = "your mail is wrong!!"; }
Validation.nameVal valid = new Validation.nameVal();
bool isname = valid.isName(TextBox1.Text);
if (!isname)
{ Label2.Text = "Your name is wrong!!"; }
else if (isname==null)
{ Label2.Text = "Please fill in your name"; }
if (isname && ismail)
{
{ Label1.Text = null; Label2.Text = null;
Label3.Text = "Your message has been send!";}
}
}
}
使用此代碼,我有一個空例外。
你從哪裏得到空指針異常? – Gabe 2011-02-06 23:10:30
你在哪裏有一個空指針異常? – ChrisF 2011-02-06 23:10:48