我已经使用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