Link to home
Start Free TrialLog in
Avatar of jazz__man
jazz__man

asked on

Links on masterpage are not working

Hi

I have the following links on my web page ...

<ul>
            <li><a href="Home.aspx">Home</a></li>
            <li><a href="ClientApplicationForm.aspx">Enquiry Form</a></li>
        </ul>

The links are on the masterpage and work fine while not on the server however when uploaded they do not work.

Your help would be appreciated.
Avatar of russellC
russellC
Flag of United States of America image

What error are u getting? 404, page not found?  Check your file locations.
Avatar of jazz__man
jazz__man

ASKER

Its a "page not found" error, its losing the correct paths because the contained links are on a masterpage.
use

<ul>
  <li><a href="~/Home.aspx" runat=server>Home</a></li>
  <li><a href="~/ClientApplicationForm.aspx" runat=server>Enquiry Form</a></li>
</ul>

HainKurt,

Thanks but no joy.
ASKER CERTIFIED SOLUTION
Avatar of russellC
russellC
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
"Thanks but no joy" does not explain :)
do you have link?
if not, post the rendered html from my post...
check the links and tell what they should be...
they work fine on server, and then you upload to where?
Hi,

I am using a hosting company for my website.

When debugging on my machine the links which are on the master page work correctly with what I had on my initial post. When I upload the website to my webserver the links are not mapped correctly and I get a "page not found" error because it is looking in the wrong directory.

so, you can give the link on your hosting company...

what code are you using now, and whet is rendered on the page? and what they should be?
runat server worked
that one suggested @36329918 which includes runat=server

and // or / does not make any difference...

please explain why

<li><a href="~//Home.aspx" runat=server>Home</a></li>

worked but not

<li><a href="~/Home.aspx" runat=server>Home</a></li>
Asp string / is an escape char.  You might have also been able to use @ in front of the string to say hey ignore the escape chars.  
This is aspx code not C# code...

<li><a href="~/Home.aspx" runat=server>Home</a></li>
<li><a href="~//Home.aspx" runat=server>Home</a></li>
<li><a href="~///Home.aspx" runat=server>Home</a></li>
<li><a href="~////Home.aspx" runat=server>Home</a></li>

all give the same result, no matter what code behind file is vb or C# or something else... To me he forgot to add runat=server first, which I suggested, then added and accepted the one you posted... I am not convinced yet :)
That's not correct /Home & //Home may possibly be different when talking about file locations.  Which is what we were doing here.  If this link is run at server or not the same file reference is made.   I mostly see this with File I/O.
russellC, can you reproduce this behaviour, I mean "~/some_page.aspx" and "~//some_page.aspx" behaves differently?
here is a link on path examples in C sharp.

http://www.dotnetperls.com/path

if you look your original suggestion did not work either.
but we are talking about aspx code not C# or C++ code...
I tested it on root and on sub folder with ~\,~\\,~\\\,~\\\\ on aspx pages with both vb & c# code behind pages...
they all give the same result... ~\ is the root, after that each \ goes to root again, which is redundant...

can you show that they run differently with a sample

 
"if you look your original suggestion did not work either"
I am not sure about this, to me he forgot to add runat=server and just put "~\" after my post then after your post he added runat=server and it worked :) still waiting for users input on this...
Yes I have seen this in the past with apache running a simulated IIS server and I believe we just did with this question.
in our case we dont have any apache server running in a simulated mode or something else... it is not mentioned anywhere, and it is not in the zone list of this post... I am still waiting for this question to reopen and user input for this issue...
still waiting for a response...
Actually I am not asking for why

<a href="~/Home.aspx" runat=server>Home</a>

did not work and why

<a href="~//Home.aspx" runat=server>Home</a></li>

worked. If you look at his comment "runat server worked", which I already have it in my post... To me, it looks like he first tried

<a href="~/Home.aspx">Home</a>

which does not work obviously, then after a few post, he added "runat=server" and he said "runat server worked" and accepted the solution... even if thats the case, should not the first post does not deserve any points?

I see this user is active and still I could not get my answer... I just want to know whether

<a href="~/Home.aspx">Home</a>

worked or did not not work! Based on his comment, he accepted an answer after saying "ruan at worked" which I posted at first place...

I am not asking why "/" did not work and why "//" worked! I just want to know what is the solution and wheteher my post worked or not!