0
votes

I put some RequiredFieldValidators on some textboxes, and unfortunately once I did and attempted to run the compiler, everything compiled but in my attempts to test the page the page did not run. Instead, I received a server error:

Server Error in '/' Application.

WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive). Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive).

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. Please add a ScriptResourceMapping named jquery(case-sensitive).]
System.Web.UI.ClientScriptManager.EnsureJqueryRegistered() +2287470
System.Web.UI.WebControls.BaseValidator.RegisterUnobtrusiveScript() +10 System.Web.UI.WebControls.BaseValidator.OnPreRender(EventArgs e) +9830941 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.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974

When I remove them, the page loads fine, and I guess I'm wanting to know what I'm missing here?

Code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="frmPersonnel.aspx.cs" Inherits="frmPersonnel" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/CIS407A_iLab_ACITLogo.jpg" PostBackUrl="~/frmMain.aspx" />
        <br />

    </div>
        <%--Panel One: Holds the form with labels, textboxes, and buttons--%>
        <asp:Panel ID="Panel1" runat="server" Height="250px" HorizontalAlign="Left" Width="500px" style="margin-left: 75px">
           <%--Label 1 & Textbox 1--%>        
             <asp:Label ID="Label1" runat="server" Text="First Name:" width="88px"></asp:Label>
            <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="rfFirstName" runat="server" ErrorMessage=" Field cannot be blank" ForeColor="Red" ControlToValidate="txtFirstName"></asp:RequiredFieldValidator>
            <br />
           <%--Label 2 & Textbox 2--%>       
            <asp:Label ID="Label2" runat="server" Text="Last Name:" width="88px"></asp:Label>
            <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="rfLastName" runat="server" ErrorMessage=" Field cannot be blank" ForeColor="Red" ControlToValidate="txtLastName"></asp:RequiredFieldValidator>
            <br />
           <%--Label 3 & Textbox 3--%>       
            <asp:Label ID="Label3" runat="server" Text="Pay Rate:" width="88px"></asp:Label>
            <asp:TextBox ID="txtPayRate" runat="server"></asp:TextBox>
            <asp:RequiredFieldValidator ID="rfPayRate" runat="server" ErrorMessage=" Field cannot be blank" ForeColor="Red" ControlToValidate="txtPayRate"></asp:RequiredFieldValidator>
            <br />
           <%--Label 4 & Textbox 4--%>       
            <asp:Label ID="Label4" runat="server" Text="Start Date:" width="88px"></asp:Label>
            <asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Format: MM/DD/YYYY" ForeColor="Red" ControlToValidate="txtStartDate" ValidationExpression="^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$"></asp:RegularExpressionValidator>
            <br />
           <%--Label 5 & Textbox 5--%>       
            <asp:Label ID="Label5" runat="server" Text="End Date:" width="88px"></asp:Label>
            <asp:TextBox ID="txtEndDate" runat="server"></asp:TextBox>
            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Format: MM/DD/YYYY" ForeColor="Red" ControlToValidate="txtEndDate" ValidationExpression="^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$"></asp:RegularExpressionValidator>
            <br />
            <br />
            <%--Buttons for Submit and Cancel--%>      
            <asp:Button ID="btnSubmit" runat="server" BackColor="#009900" BorderColor="#99CC00" BorderStyle="Solid" ForeColor="#CCFF66" Text="Submit" style="margin-left: 89px" />
            &nbsp;&nbsp;
            <br />
            <br />
        </asp:Panel>
    </form>
</body>
</html>
1
Have a look at this question on the ASP.NET forums forums.asp.net/t/… it seems to resolve your issue. Do you know what version of .NET you are targeting?Master Yoda
Not sure which version but I'm using Visual Studio 2010 if that helps, thank you for link. Checking it out now.Sierra
If you open up your web.config file in the solution explorer you should see the target framework. Its hard to tell if its 4.0 or 4.5 but its most likely 4.0 going by the version of visual studio you are using and what came bundled with the software at the time. Basically you need to specify how the built in unobtrusive Javascript controls are enabled.Master Yoda

1 Answers

1
votes

Try adding the following to your Web.Config file:

    <appSettings>
      <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
    </appSettings>