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 October 29th, 2011, 01:33 PM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile Navigation

Hi all,

In master page when I added jscript file then it is referenced as ../Scripts/ then it works fine but when I change it to ~/Scripts/ then it does not work, why? Folder structure is same as stated in book.

Code:
<script src="../Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
Thanks...
 
Old October 29th, 2011, 02:08 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

In order for the ~ to work, you need to use a control with runat="server" on it as the ~ is expanded server side. However, if you try to do that with a JS file, .NET tries to execute that code on the server which results in an error.

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 October 29th, 2011, 02:20 PM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

Hi Imar,
Thanks for your prompt reply. But again one more confusion.

It is working fine with stylesheet files.

Code:
<link href="~/Styles/Styles.css" type="text/css" rel="stylesheet" media="screen" />
Above code is working fine with both ../ and ~/ although it does not contain any runat attribute.
 
Old October 29th, 2011, 02:27 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yes, that works because the style sheet is placed inside the <head> with a runat=server attribute. Remove that, or place the CSS in the body and it will no longer work. Not sure why they didn't do the same trick for JS files.

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 October 29th, 2011, 02:37 PM
Friend of Wrox
 
Join Date: Oct 2009
Posts: 341
Thanks: 14
Thanked 3 Times in 3 Posts
Smile

Quote:
Not sure why they didn't do the same trick for JS files.
Hmmmm.....

I think we both are best of searching the answer, and whoever finds it, must reply here....

Still many thanks....





Similar Threads
Thread Thread Starter Forum Replies Last Post
Navigation - ch7. wingri BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 4 April 8th, 2008 08:29 AM
Navigation sg48 ASP.NET 2.0 Basics 2 February 13th, 2008 12:18 PM
Navigation volsha Dreamweaver (all versions) 1 July 20th, 2007 03:19 PM
navigation nidheeshkayal ASP.NET 2.0 Basics 0 March 16th, 2006 07:05 AM
Navigation JonnyRPI HTML Code Clinic 1 July 6th, 2003 05:33 AM





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