Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 8th, 2014, 02:46 PM
Registered User
 
Join Date: Mar 2014
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch 9 Try It Out pg 301

Step 9 states to drag the user control ContactForm.ascx into the main content area. My control declaration in markup looks like this:

<%@ Page Title="Contact Us" Language="C#" MasterPageFile="~/MasterPages/Frontend.master" AutoEventWireup="true" CodeFile="Contact.aspx.cs" Inherits="About_Contact" %>

<%@ Register src="~/Controls/ContactForm.ascx" tagname="ContactForm" tagprefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" runat="Server">

<uc1:ContactForm ID="ContactForm1" runat="server" />

</asp:Content>

I used the downloaded code files to make sure I didn't have any typos and also cleared the browser cache in Firefox, Chrome, and IE 10 with the same results. After I save and open the file in my browser, I get the following 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.EnsureJqueryRegi stered() +2178762
System.Web.UI.WebControls.BaseValidator.RegisterUn obtrusiveScript() +10
System.Web.UI.WebControls.BaseValidator.OnPreRende r(EventArgs e) +9710049
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.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

It appears to be a problem with the validation controls because when I remove them from the contact form, the page loads in the browser and there are no error message.

Last edited by Adrianne; March 9th, 2014 at 01:30 AM..
 
Old March 10th, 2014, 10:29 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Are you using ASP.NET 4.5/4.5.1 and VS 2012/2013 instead of ASP.NET / VS 2010 that the book is targeting?

If so, these versions need a setting in web.config like this:
Code:
<configuration>
  <appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
  </appSettings>
  ...
</configuration>
In these versions, the validation controls assume that jQuery is available, and this setting turns that assumption off.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old March 10th, 2014, 06:11 PM
Registered User
 
Join Date: Mar 2014
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am using VS 2013 Express 4.5.50938. I assumed the version
I have would be backwards compatible automatically, but
apparently not.

Thanks for the line of code to add to my web.config file. That
did the trick and I was able to reapply the validation without
any additional errors.

Worked like a charm,
Adrianne
 
Old March 11th, 2014, 06:56 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Great, good to hear it worked.

Most of the framework is backwards compatible but this is an area that has changed somewhat between versions.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!





Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch.2 pg.43 Try It Out Thibbs23 BOOK: Beginning Android Application Development 1 February 21st, 2012 10:40 AM
pg 301... Connecting a data source problems... richv BOOK: Beginning SharePoint 2010 Development 1 September 2nd, 2010 04:16 AM
CH 12 page 301 (overloaded method) jon4554 BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 1 March 2nd, 2010 03:02 PM
CH 5 pg 160 wadesmart BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 8 November 12th, 2003 11:23 PM
CH 3 pg 76 wadesmart BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 2 October 26th, 2003 08:46 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.