0
votes

I'm trying to add a validator to my template in DetailsView Control, but at run time I encounter to this 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.

Below, is my program in Visual Studio 2017.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="InsertTitleByTemplate.aspx.cs" Inherits="WebAppAspAzDataConn.InsertTitleByTemplate" %>

<!DOCTYPE html>

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

            <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="title_id" DataSourceID="SqlDataSource1"
                OnItemInserted="DetailView_ItemInsert" OnItemCommand="DetailView_ItemCommand"
                DefaultMode="Insert" Height="50px" Width="364px" >
                <Fields>
                    <asp:BoundField DataField="title" HeaderText="Title" SortExpression="title" />
                    <asp:TemplateField HeaderText="Price">
                        <EditItemTemplate> 
                            <asp:TextBox ID="price" runat="server"
                                Text='<%# Bind("price") %>' />
                            <br />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="price" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>

                            <br />
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Publish Date">
                        <EditItemTemplate >
                            <asp:TextBox ID="pub_date" runat="server" 
                                Text='<%# Bind("pubdate") %>' />
                        </EditItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="notes" HeaderText="Notes" SortExpression="notes" />
                    <asp:CommandField ShowInsertButton="True" />
                </Fields>
            </asp:DetailsView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:mybookstoreConnectionString1 %>" DeleteCommand="DELETE FROM [titles] WHERE [title_id] = @title_id" InsertCommand="INSERT INTO [titles] ([pub_id], [au_id], [title], [price], [pubdate], [notes]) VALUES (@pub_id, @au_id, @title, @price, @pubdate, @notes)" ProviderName="<%$ ConnectionStrings:mybookstoreConnectionString1.ProviderName %>" SelectCommand="SELECT [title_id], [pub_id], [au_id], [title], [price], [pubdate], [notes] FROM [titles]" UpdateCommand="UPDATE [titles] SET [pub_id] = @pub_id, [au_id] = @au_id, [title] = @title, [price] = @price, [pubdate] = @pubdate, [notes] = @notes WHERE [title_id] = @title_id">
                <DeleteParameters>
                    <asp:Parameter Name="title_id" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="pub_id" Type="Int32" />
                    <asp:Parameter Name="au_id" Type="Int32" />
                    <asp:Parameter Name="title" Type="String" />
                    <asp:Parameter Name="price" Type="Decimal" />
                    <asp:Parameter Name="pubdate" Type="DateTime" />
                    <asp:Parameter Name="notes" Type="String" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="pub_id" Type="Int32" />
                    <asp:Parameter Name="au_id" Type="Int32" />
                    <asp:Parameter Name="title" Type="String" />
                    <asp:Parameter Name="price" Type="Decimal" />
                    <asp:Parameter Name="pubdate" Type="DateTime" />
                    <asp:Parameter Name="notes" Type="String" />
                    <asp:Parameter Name="title_id" Type="Int32" />
                </UpdateParameters>
            </asp:SqlDataSource>
        </div>
    </form>
</body>
</html>
1
Have you tried acting on the directive given in exception message?Tanveer Badar

1 Answers

0
votes

Check if your web.config has the following set properly:

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