Custom navigation fails on localhost

For general questions and discussions specific to the AbleCommerce 7.0 Asp.Net product.
Post Reply
User avatar
bobr2k
Commander (CMDR)
Commander (CMDR)
Posts: 183
Joined: Fri Oct 26, 2007 2:31 pm
Location: Illinois

Custom navigation fails on localhost

Post by bobr2k » Thu Nov 06, 2008 11:10 am

Help! we have a customized navigation scriplet which runs fine on the server using a slash without the tilde such as:
<li><a href="/Basket.aspx">View Cart</a></li>
which shows on the status line when you hover over it as "http://www.storename.com/Basket.aspx" - everything works great.
However when it runs on the localhost it comes up "http://localhost/Basket.aspx" and does not run because the storename is missing.
If I add a tilde
<li><a href="~/Basket.aspx">View Cart</a></li>
the status line resolves as: http://localhost/storename/~/basket.aspx[/quote] which of course does not run. I've been scanning html tutorials and AC7 elements which uses both types of urls but I can't determine why this is failing or how to correct it. Does anyone have any other ideas? Is there a way to tell the site it is running from the server or from the localhost so it will resolve the url properly?
Bob R.
"Bills travel through the mail at twice the speed of checks." -- Steven Wright

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Custom navigation fails on localhost

Post by mazhar » Thu Nov 06, 2008 11:16 am

Have you tried by removing the both ~/

User avatar
bobr2k
Commander (CMDR)
Commander (CMDR)
Posts: 183
Joined: Fri Oct 26, 2007 2:31 pm
Location: Illinois

Re: Custom navigation fails on localhost

Post by bobr2k » Thu Nov 06, 2008 11:52 am

mazhar wrote:Have you tried by removing the both ~/
Yes - when I remove both from the links I run into a problem in checkout so if a user tries to go to products while in checkout the url resolves to "http://www.storename.com/checkout/search.aspx" (the same thing occurs for contact us, etc.)
Bob R.
"Bills travel through the mail at twice the speed of checks." -- Steven Wright

User avatar
bobr2k
Commander (CMDR)
Commander (CMDR)
Posts: 183
Joined: Fri Oct 26, 2007 2:31 pm
Location: Illinois

Re: Custom navigation fails on localhost

Post by bobr2k » Thu Nov 06, 2008 12:44 pm

I found this but I don't understand how to apply it:
Use this in any ASP.NET page to get the application path. For example, if you run this function in http://localhost/pathtest/test.aspx, the function will return http://localhost/pathtest/
From: Get Application Path [C# / ASP.NET] http://www.thejackol.com/2004/09/22/get ... -c-aspnet/
It sounds like it has something to do with resolving localhost from the master page. (Now if I just understood master pages) :oops: (still searching)
Bob R.
"Bills travel through the mail at twice the speed of checks." -- Steven Wright

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Custom navigation fails on localhost

Post by AbleMods » Fri Nov 07, 2008 9:41 pm

You're confusing HTML link tags with ASP.NET link tags. The syntax is very different between them.

Code: Select all

<li><a href="~/Basket.aspx">View Cart</a></li>
is an HTML link tag, not ASP.Net.

If you want an HTML tag to render relative to the page that contains it, use "./"

So the correct syntax would be

Code: Select all

<li><a href="./Basket.aspx">View Cart</a></li>
If you want the URL to be absolute from the root of the site, you use "../"

So no matter where the page that contains the link is located,

Code: Select all

<a href="../Basket.aspx">
will always result in http://www.mysite.com/basket.aspx
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
bobr2k
Commander (CMDR)
Commander (CMDR)
Posts: 183
Joined: Fri Oct 26, 2007 2:31 pm
Location: Illinois

Re: Custom navigation fails on localhost

Post by bobr2k » Sat Nov 08, 2008 9:24 am

Unfortunately Joe, I've tried both of those and they don't always work either.
Bob R.
"Bills travel through the mail at twice the speed of checks." -- Steven Wright

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Custom navigation fails on localhost

Post by AbleMods » Sat Nov 08, 2008 10:18 am

What's the full URL of the page you want that link on?
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
bobr2k
Commander (CMDR)
Commander (CMDR)
Posts: 183
Joined: Fri Oct 26, 2007 2:31 pm
Location: Illinois

Re: Custom navigation fails on localhost

Post by bobr2k » Sat Nov 08, 2008 11:02 am

SolunarServices wrote:What's the full URL of the page you want that link on?
When it's on the server http://www.webermeats.com when it's on local http://localhost/weberdev/
(I've think I've got that right :? ) ... It's not just one link but all navigation links in the header, including basket, contact us, awards, our history, etc. the way we are using it seems to work on the server but I seem to need an entirely different setup on the localhost and even then links sometimes fail when I come out of admin to the store or when I try to go from basket to one of the other pages, checkout gets stuck in the middle of the link and the link fails.
Bob R.
"Bills travel through the mail at twice the speed of checks." -- Steven Wright

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Custom navigation fails on localhost

Post by AbleMods » Sat Nov 08, 2008 1:23 pm

Is this in an AC7 scriptlet or something you've built directly into an ASPX page?
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
bobr2k
Commander (CMDR)
Commander (CMDR)
Posts: 183
Joined: Fri Oct 26, 2007 2:31 pm
Location: Illinois

Re: Custom navigation fails on localhost

Post by bobr2k » Sat Nov 08, 2008 3:15 pm

SolunarServices wrote:Is this in an AC7 scriptlet or something you've built directly into an ASPX page?
It's in a custom conlib -
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CommonNav.ascx.cs" Inherits="ConLib_Custom_CommonNav" %>
<ul id="<%= NavIdName %>" class="nav clearfix">
<li class="first"><a href="Search.aspx">Products</a> </li>
<li><a href="#">Processing</a>&nbsp;
<ul class="subnav">
<li><a href="/Assets/BeefOptions.pdf" target="_blank">Beef Processing</a></li>
<li><a href="/Assets/PorkOptions.pdf" target="_blank">Pork Processing</a></li>
<li><a href="/Assets/Venison.pdf" target="_blank">Venison Processing</a></li>
</ul>
</li>
<li><a href="/OurHistory.aspx">Our History</a>&nbsp; </li>
<li><a href="/Awards.aspx">Awards</a>&nbsp; </li>
<li><a href="/ContactUs.aspx">Contact Us</a>&nbsp; </li>
<li><a href="/Basket.aspx">View Cart</a>&nbsp; </li>
<li></li>
<li></li>
<li class="last"><a href="/Members/MyAccount.aspx">Account&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</a>
<ul class="subnav">
<li><asp:HyperLink ID="LoginLogoutLink" runat="server" /></li>
<li><a href="/Members/MyAccount.aspx">My Account</a></li>
<li><a href="/Members/MyWishlist.aspx">My Wishlist</a></li>
<li><a href="/FindWishlist.aspx">Find Wishlist</a></li>
<asp:PlaceHolder ID="PlaceholderAdminLink" runat="server" Visible="false"><li><a href="/Admin/">Admin</a></li></asp:PlaceHolder>
</ul>
</li>
</ul>
Bob R.
"Bills travel through the mail at twice the speed of checks." -- Steven Wright

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Custom navigation fails on localhost

Post by AbleMods » Sat Nov 08, 2008 6:44 pm

Let's practice on one link. Once we get it working, we'll fix the others.

Instead of this:

Code: Select all

<a href="Search.aspx">Products</a>
Try this:

Code: Select all

<asp:LinkButton ID="LinkButton1" runat="server" Text="Products" PostBackUrl="~/Search.aspx"></asp:LinkButton>
Let me know if that works.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

User avatar
bobr2k
Commander (CMDR)
Commander (CMDR)
Posts: 183
Joined: Fri Oct 26, 2007 2:31 pm
Location: Illinois

Re: Custom navigation fails on localhost

Post by bobr2k » Mon Nov 10, 2008 3:40 pm

SolunarServices wrote:Let's practice on one link. Let me know if that works.
Looks to me like it's working. I can probably get the rest by following the same procedure. I just knew there was a way to get it to work. Thanks Joe! :mrgreen:
Bob R.
"Bills travel through the mail at twice the speed of checks." -- Steven Wright

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Custom navigation fails on localhost

Post by AbleMods » Mon Nov 10, 2008 4:10 pm

You are most welcome.

If you use more Link Button controls on the same page, just be sure to change the ID value so that each control has a unique ID.

Something as simple as:
ID="LinkButton1"
ID="LinkButton2"
.
.
.

is completely fine. The ID is only used to reference the control through programming, so in your case it's not really all that critical.
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

Post Reply