Last post Jul 02, 2015 05:52 PM by mostafasydney
Member
26 Points
53 Posts
Jun 25, 2015 02:34 PM|EasyHero|LINK
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
C
Contributor
4407 Points
1264 Posts
Jun 25, 2015 03:54 PM|mostafasydney|LINK
Do you have jquery.validate.js installed and reference in your page?
Jun 25, 2015 05:42 PM|EasyHero|LINK
Jun 25, 2015 06:18 PM|mostafasydney|LINK
You need to add it to BundleConfig.cs in App_Start folder, please follow the way how other packages are added there.
Jul 02, 2015 07:41 AM|EasyHero|LINK
i'm using the c# language. there is no App_Start folder in my project because i created it from scratch. so i don't kn how to implement that. Thanks
Jul 02, 2015 05:52 PM|mostafasydney|LINK
Well, to get the idea how the files are created and organized in App_Start folder do the following steps:
Hope this will help.
Member
26 Points
53 Posts
RequiredField Validation in visual studio 2013
Jun 25, 2015 02:34 PM|EasyHero|LINK
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
but i receive the following error in stack trace
C
Contributor
4407 Points
1264 Posts
Re: RequiredField Validation in visual studio 2013
Jun 25, 2015 03:54 PM|mostafasydney|LINK
Do you have jquery.validate.js installed and reference in your page?
C
Mostafa
If this post helps you to resolve your problem, don't forget to "Mark as Answer"
Member
26 Points
53 Posts
Re: RequiredField Validation in visual studio 2013
Jun 25, 2015 05:42 PM|EasyHero|LINK
C
Contributor
4407 Points
1264 Posts
Re: RequiredField Validation in visual studio 2013
Jun 25, 2015 06:18 PM|mostafasydney|LINK
You need to add it to BundleConfig.cs in App_Start folder, please follow the way how other packages are added there.
C
Mostafa
If this post helps you to resolve your problem, don't forget to "Mark as Answer"
Member
26 Points
53 Posts
Re: RequiredField Validation in visual studio 2013
Jul 02, 2015 07:41 AM|EasyHero|LINK
i'm using the c# language. there is no App_Start folder in my project because i created it from scratch. so i don't kn how to implement that. Thanks
C
Contributor
4407 Points
1264 Posts
Re: RequiredField Validation in visual studio 2013
Jul 02, 2015 05:52 PM|mostafasydney|LINK
Well, to get the idea how the files are created and organized in App_Start folder do the following steps:
Hope this will help.
C
Mostafa
If this post helps you to resolve your problem, don't forget to "Mark as Answer"