Solved

Hyperlink like a button with relative (not absolute) links

Posted on 2009-05-04
5
372 Views
Last Modified: 2012-05-06
Hi
This follows on from question 22578710 where a hyperlink need to look like a button.

I'd like the link <input type="button" value="Return to Main" onclick="location.href='/Default.aspx';" />

to be the same location as what ~/Default.aspx would generate, but ~/Default.aspx doesn't work. Neither does ../Default.aspx or ./Default.aspx - it takes me to root not a level down

(alteratively a solution with ASP.net hyperlink styled like a hyperlink would do)

Thank-you in advance
0
Comment
Question by:rwallacej
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 10

Expert Comment

by:cdebel
ID: 24293950
This is how you should define a LinkButton in asp.net:

<asp:LinkButton ID="LinkButton2" runat="server" PostBackUrl="../default.aspx">LinkButton</asp:LinkButton>
0
 

Author Comment

by:rwallacej
ID: 24294157
hi
I tried the link button (see the original question http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_23765789.html) but it doesn't look like a button
thanks
0
 
LVL 10

Expert Comment

by:cdebel
ID: 24294168
because the it doesn't look flat?

Just set the background color, you won't get this 3D style anymore...
0
 
LVL 10

Accepted Solution

by:
cdebel earned 500 total points
ID: 24294195
forget what i said.  It apply to asp:button... not linkbutton.

Use an ASP:BUTTON like this:
<asp:Button ID="Button1" runat="server" Text="Button" />

and in the code-behind you can do this:
    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Page.Response.Redirect("../default.aspx")
    End Sub
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question