Solved

Hyperlink like a button with relative (not absolute) links

Posted on 2009-05-04
5
366 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
  • 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

896 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now