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 January 16th, 2012, 03:40 AM
Authorized User
 
Join Date: Dec 2011
Posts: 39
Thanks: 9
Thanked 0 Times in 0 Posts
Default Quick Question about image paths.

I followed the instructions on how to return a string based on a boolean item in a grid and instead of returning yes or no I returned a path to a yes and no icon stored in my main images folder.

My question is how come when I supplied "~/Images/yes-icon.jpg" as a path it didn't work but when I erased the tilda it did work?

Will omitting the tilda cause any problems or will it work just as well as "~/"?


Thanks.
 
Old January 16th, 2012, 03:46 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Without the ~ your image will always be looked for in the root of the server. With that character, the path will be expanded to the current application which may or may not be the root of the server (it could be an additional application folder such as /myApp).

Why it didn't work is hard to say without seeing the relevant code. Maybe the image you assigned it to was a plain img element and not a server control?

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 January 16th, 2012, 03:49 AM
Authorized User
 
Join Date: Dec 2011
Posts: 39
Thanks: 9
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Imar View Post
Without the ~ your image will always be looked for in the root of the server. With that character, the path will be expanded to the current application which may or may not be the root of the server (it could be an additional application folder such as /myApp).

Why it didn't work is hard to say without seeing the relevant code. Maybe the image you assigned it to was a plain img element and not a server control?

Imar
Yes, it was just a plain img. What control should I use instead, just change it to an asp image?

And would it be possible to put this function along with the one that returns yes or no label in a static class in my app_code folder so I can call it on any grid on any page?

Thanks for the quick reply.

Last edited by IceThatJaw; January 16th, 2012 at 03:56 AM..
 
Old January 16th, 2012, 08: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

You can use an asp:Image or an img with a runat="server" attribute. Check out page 240 and further and the exercice + How It Works section for a detailed explanation.

And yes, you could move this code to App_Data in a static class and then use it elsewhere.

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
Just a quick Question: tariq BOOK: Beginning ASP.NET 4 : in C# and VB 9 September 1st, 2010 04:19 PM
One quick question helovamut BOOK: Professional CodeIgniter ISBN: 978-0-470-28245-8 1 March 16th, 2009 10:16 AM
Quick question put image in table cell user0b PHP How-To 0 June 26th, 2008 10:56 PM
quick question treasacrowe Classic ASP Databases 2 August 30th, 2004 08:27 AM
Hi. Question regarding physical paths in XSL. vlad027 XSLT 0 June 26th, 2003 04:33 PM





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