Quantcast
Channel: Oracle, MySQL, Sybase, Informix and other databases
Viewing all articles
Browse latest Browse all 1350

RequiredField Validation in visual studio 2013

$
0
0

I used a required field validation control to validate a textbox using the following lines of codes

<asp:Label ID="Label25" runat="server" Text="School"></asp:Label>
<asp:TextBox ID="schl" runat="server" Width ="320px"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="*" ControlToValidate="schl" Text="*"></asp:RequiredFieldValidator>

<asp:Button ID="addschool" runat="server" Text="Add" CssClass="button" BackColor="#333333" BorderColor="Silver" OnClick="addschool_Click" BorderWidth="2px" Width="150px" />

this is the back code of the button

protected void addschool_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    error.Text = "";
                    MySqlConnection conn = new MySqlConnection(connection);
                    MySqlCommand addschool = new MySqlCommand("insert into pla20132014.schools (Departments, Schools) values(@dept, @schl)", conn);
                    MySqlDataReader read;
                    conn.Open();
                    addschool.Parameters.Add("@dept", MySqlDbType.VarChar).Value = dept.Text;
                    addschool.Parameters.Add("@schl", MySqlDbType.VarChar).Value = schl.Text;
                    read = addschool.ExecuteReader();
                    read.Close();
                    conn.Close();
                    error.ForeColor = Color.Green;
                    error.Text = "Upload Successful";

                }
            }
            catch(MySqlException myex)
            {
                error.Text = myex.Message;
            }
            catch(Exception ex)
            {
                error.Text = "/n " + ex.Message;
            }
        }

but i receive the following error in stack trace

[InvalidOperationException: WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive).]
   System.Web.UI.ClientScriptManager.EnsureJqueryRegistered() +2287754
   System.Web.UI.WebControls.BaseValidator.RegisterUnobtrusiveScript() +10
   System.Web.UI.WebControls.BaseValidator.OnPreRender(EventArgs e) +9831213
   System.Web.UI.Control.PreRenderRecursiveInternal() +83
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Control.PreRenderRecursiveInternal() +155
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974
i really don't know what is wrong because i use same code in visual studio 2010 and it works perfectly. Thanks for your assistance

Viewing all articles
Browse latest Browse all 1350

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>