Re: VS.NET, Default Web Site, and relative paths...
Mark Kucera <[email protected]>
| Newsgroups | gmane.comp.windows.devel.dotnet.web |
|---|---|
| Message-ID | <[email protected]> |
The ~/ will work for HTML controls as long as you add runat="server" to the control. Usually whenever I add runat="server" to a control just so that I can use ~/ then I also make sure to add EnableViewState="false". The problem that you'll notice is that this works great for images and hyperlinks when used with the traditional <a> or <img> tags. The method breaks down in table cells or any control that allows you to specify background images. i.e. <td runat="server" enableviewstate="false" background="~/images/background1.gif"></td> This example won't work. There are a couple of other items that won't work by adding runat="server", notably client side <script> tags the reference a js file, because adding runat="server" to a client side script tag gives the control a whole new meaning. i.e. <script language="javascript" src="~/scripts/my.js"></script> Also you'll have problems w/ <link> tags that reference .css style sheets. Hopefully this might help you some. At least you won't have to convert all your <IMG> to <asp:Image> and <a href> to <asp:HyperLink> tags... Good Luck MK -----Original Message----- From: Discussion of building .NET applications targeted for the Web [mailto:[email protected]] On Behalf Of Ben Joyce Sent: Thursday, December 21, 2006 6:00 AM To: [email protected] Subject: Re: [DOTNET-WEB] VS.NET, Default Web Site, and relative paths... I suppose I could use an ASP Server Image control for all my images, seems a bit of an overkill though. On 12/21/06, Ryan Heath <[email protected]> wrote: > In web pages/controls code, you can use ResolveUrl("~/yourpath") too. > > HTH > // Ryan > > On 12/21/06, Ben Joyce <[email protected]> wrote: > > Hi all. Thanks for the replies, I trawled through my application > > making all the required changes. > > > > It's a bit frustrating; I can use the ~/ in client-side paths for CSS > > for not for JavaScript files, also it does not work for IMG tags but > > does for the server-controls. > > > > Oh well. > > > > Ben > > > > On 12/14/06, Fritts,Jordan <[email protected]> wrote: > > > Ben, > > > > > > I know exactly what you're talking about, and there is any easy way > > > around it. I haven't used .NET for some time, but I just did this on my > > > machine. > > > > > > Instead of entering "http://localhost/", just delete the trailing slash > > > so you have "http://localhost" > > > > > > Thanks, > > > Jordan > > > > > > =================================== > > > This list is hosted by DevelopMentor(r) http://www.develop.com > > > > > > View archives and manage your subscription(s) at http://discuss.develop.com > > > > > > > =================================== > > This list is hosted by DevelopMentor(r) http://www.develop.com > > > > View archives and manage your subscription(s) at http://discuss.develop.com > > > > =================================== > This list is hosted by DevelopMentor(r) http://www.develop.com > > View archives and manage your subscription(s) at http://discuss.develop.com > =================================== This list is hosted by DevelopMentor(r) http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com