类型或命名空间定义,预期文件结尾
public partial class contact : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click1(object sender, EventArgs e)
{
if (TextBox1.Text == "")
{
/* Label2.Text = "name is compulasry";*/
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('name is compulasry');", true);
}
else
{
SqlConnection con = new SqlConnection(@"Data Source=SYSTEM2\SQLEXPRESS;Initial Catalog=amresh;Integrated Security=True");
SqlCommand cmd;
con.Open();
cmd = new SqlCommand("insert into Deatil values('"+ TextBox1.Text +"')", con);
cmd.ExecuteNonQuery();
ClearInputs(Page.Controls);
con.Close();
}
void ClearInputs(ControlCollection ctrls)
{
foreach (Control ctrl in ctrls)
{
if (ctrl is TextBox)
((TextBox)ctrl).Text = string.Empty;
ClearInputs(ctrl.Controls);
}
}
}
}