我试图运行该应用程序,但它显示2错误。红线在Label1.Txt和Label2.Txt下。请参阅下面的代码在执行当前Web请求期间生成了未处理的异常asp net
public object Label1 { get; private set; }
public object Label2 { get; private set; }
protected void Page_Load(object sender, EventArgs e)
{
var username = HttpContext.Current.Session["username"];
if (username == null)
{
Response.Redirect("login.aspx");
}
}
protected void submitt_Click(object sender, EventArgs e)
{
try
{ con.Open();
SqlCommand command = new SqlCommand("insert into [Students] values ('" + ID.Text + "','" + FN.Text + "', '" + LN.Text + "', '" + Country1.Text + "', '" + gender.SelectedValue + "', '" + email.Text + "', '" + passportNo.Text + "', '" + PlaceOfIssue.Text + "', '" + issue.Text + "', '" + Expiry.Text + "', '" + VisaNo.Text + "', '" + VisaExpiry.Text + "', '" + EmiratesNo.Text + "', '" + EmiaratesExpiry.Text + "');", con);
command.ExecuteNonQuery();
con.Close();
Label1.Text = "Uploaded Successfully";
}
catch (Exception ex)
{
Label2.Text = "Same data cannot be submitted again";
}
}
}
}
有“文本”被宣布为两个标签下面? – Faegy
你使用网页表单吗? – Saif
是的,我正在使用网页形式,文本将只显示在提交按钮请求 –