Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 4.5.1 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4.5.1: in C# and VB by Imar Spaanjaars; ISBN: 978-1-118-84677-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4.5.1 : 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 April 13th, 2016, 11:31 AM
Registered User
 
Join Date: Oct 2014
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default Chapter 11 Content Delivery Network

Hi Imar,

In Chapter 11 you cover unobtrusive JavaScript validation. I followed your instructions and as usual everything worked as advertised. In the book you do not use Content Delivery Network as the source for the jQuery library, but I thought I’d try to implement it in my Web Application project. I did a lot of reading on the web and added the CDN source without any trouble. Here are the modifications I made:

Global.asax
Code:
    void Application_Start(object sender, EventArgs e)
    {
      RouteConfig.RegisterRoutes(RouteTable.Routes);
      ScriptResourceDefinition jQuery = new ScriptResourceDefinition();
      jQuery.Path = "~/Scripts/jquery-2.2.2.min.js.";
      jQuery.DebugPath = "~/Scripts/jquery-2.2.2.js";
      jQuery.CdnPath = "http://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.2.min.js";
      jQuery.CdnDebugPath = "http://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.2.js";
      jQuery.CdnSupportsSecureConnection = true;
      jQuery.LoadSuccessExpression = "window.jQuery";
      ScriptManager.ScriptResourceMapping.AddDefinition("jquery", jQuery); 
    }
Web.config
Code:
  <appSettings>
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms"/>
</appSettings>

ScriptManager
Code:
  <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnableCdn="true"  >
      <Scripts>
        <asp:ScriptReference Name="jquery" />
      </Scripts>
    </asp:ScriptManager>
Page Source partial view:
Code:
<script src="http://ajax.aspnetcdn.com/ajax/4.6/1/WebForms.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
window.WebForm_PostBackOptions||document.write('<script type="text/javascript" src="/WebResource.axd?d=pynGkmcFUV13He1Qd6_TZDK1rSI7GaESqe2XElTAO7CWQBVn5WVBZ4MtmH-WpeftFSc7dc4wnmXs-4SpZqpJCQ2&amp;t=635823490080000000"><\/script>');//]]>
</script>



<script src="http://ajax.aspnetcdn.com/ajax/4.6/1/MenuStandards.js" type="text/javascript"></script>
<script src="http://ajax.aspnetcdn.com/ajax/4.6/1/WebUIValidation.js" type="text/javascript"></script>
<script src="http://ajax.aspnetcdn.com/ajax/4.6/1/MicrosoftAjax.debug.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
(window.Sys && Sys._Application && Sys.Observer)||document.write('<script type="text/javascript" src="/ScriptResource.axd?d=D9drwtSJ4hBA6O8UhT6CQjaBRU6Z6H7p9O0STLSLg5rBf8PmRnl4mgvaWhIMV_ez6XMoUIIKH0Lvyft9wMx-mn1K9xpgrT3p2SyaN0NhYQbdjgaFJ6SvDdyemGdHEucpaI3wWXBGiOlLSdsFNYsvmTOODx6pVaODE03NGxR7Xbg1&t=ffffffffcc58dd65"><\/script>');//]]>
</script>

<script type="text/javascript">
//<![CDATA[
if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.');
//]]>
</script>

<script src="http://ajax.aspnetcdn.com/ajax/4.6/1/MicrosoftAjaxWebForms.debug.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
(window.Sys && Sys.WebForms)||document.write('<script type="text/javascript" src="/ScriptResource.axd?d=JnUc-DEDOM5KzzVKtsL1tS1fIGeXSMhL5jVbdlHHyfSurUpuo1S171n76BLe9kDe1bp92aRTLPrikgb1IAtAszNWAFCy6sKP29VeCOzcPlox9DtzCzUFdGq4Fy-s27Drv30WWrzbTeErZ2yuWIvEzeuzvitKK3msQe9zpZo5Og0E5fjP9jHIPtUi3ZaZxHQF0&t=ffffffffcc58dd65"><\/script>');//]]>
</script>

<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-2.2.2.js" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
(window.jQuery)||document.write('<script type="text/javascript" src="../Scripts/jquery-2.2.2.js"><\/script>');function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
//]]>
</script>
On page 400 of your book in the TRY IT OUT: Unobtrusive JavaScriptValidation step 9, you add a reference to “~/Scripts/WebForms/WebUIValidation.js” on the master page. However, this reference is missing in the download code for the site. In my scriptmanager I also didn’t include this reference as shown above; however, as you can see in the page source view above the CDN source is referenced for WebUIValidation.js. Why is this reference not needed?

Thanks for the great book and taking the time to reply!
 
Old April 16th, 2016, 03:12 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

>> However, this reference is missing in the download code for the site.

Is it? I see it in the folder Scripts for every chapter from 11 to 19 on my machine which contains the code I sent to Wrox.

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 April 17th, 2016, 12:15 AM
Registered User
 
Join Date: Oct 2014
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Imar,

I downloaded the current 9781118846773_Csharp_Full_Download.zip from the Wrox website and you are correct as always that it does contain the Scripts/Webforms folder. The file I had originally downloaded (9781118311806_CSharp_Download.zip) does not contain the /Webforms folder and does not have the Release folder either. Sorry for wasting your valuable time on that matter.

The real question I had was why did the CDN WebUIValidaton.js source show in the browser source view as in my original post even though I made no reference to it in the ScriptManager Scripts section and ScriptResourceMapping? Is this just something that is automatically implemented when CDN is enabled?

My apologies again for the file mixup.
 
Old April 18th, 2016, 10:13 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Good question; it's been a while since I look at this, but it looks like the validators know how to rewrite the URL to the web validation library when there's a CDN in play.

As you found out, 9781118311806 is for the previous version of the book.

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!
The Following User Says Thank You to Imar For This Useful Post:
kov2013 (April 21st, 2016)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 13 - Bonjour without Wifi network acsteester BOOK: Professional iOS Network Programming: Connecting the Enterprise to the iPhone and iPad 5 July 31st, 2013 08:55 AM
Chapter-11 Content Type Wrapper Carlw BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 1 September 4th, 2009 07:56 AM
How to do the SSRS - Custom Delivery Extension pnviv Reporting Services 1 March 17th, 2008 11:55 PM
chapter 11 figure 11-7 relative positioning pelopito BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 November 29th, 2007 06:11 AM
Error in email delivery! DiegoH BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 March 7th, 2005 04:52 PM





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