The ControlToValidate property of 'NameValid' cannot be blank
<p>i m writing a web application and i have a problem in one on my pages!
i design a admin page and i want to log in before user enter in this page!
there are three RequiredFieldValidator and a button(AddButton) in my page and i want to check the fields when user click the button but when the page is loaded the validation is checked and visual studio throw a exception:
"The ControlToValidate property of 'NameValid' cannot be blank" NameValid is one of my Validation controls in page!
and another question: what is the advantage of (using) block when you work with databases and files?</p>

<p>my class is here:</p>

<pre><code>    public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.UrlReferrer == null)
        {
            //a page for log in
            Response.Redirect("~/LogIn.aspx");
        }
    }
    protected void Page_Error(object sender, EventArgs e)
    {
        Response.Clear();
        Response.Write("&lt;h2&gt;Exception&lt;/h2&gt;&lt;br /&gt;");
        Response.Write(Server.GetLastError().Message);
        Server.ClearError();
    }
    protected void AddButton_Click(object sender, EventArgs e)
    {
        const string ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=D:\rasoul\sourcecode\ASP-PROJECTS\UniversityDataBase\DataBase\PersonDataBase.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
        using (SqlConnection con=new SqlConnection(ConnectionString))
        {
                string ID = IDField.Text.Trim();
                string Name = NameField.Text.Trim();
                string LastName = LastNameField.Text.Trim();
                DataSet data = new DataSet();
                SqlCommand cmd = con.CreateCommand();
                cmd.CommandText = String.Format("insert into StudentTable values('{0}','{1}','{2}')", ID, Name, LastName);
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
        }
    }
}
</code></pre>

<p>what should i do?</p>
