Solved

Hyperlink like a button with relative (not absolute) links

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

757 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

20 Experts available now in Live!

Get 1:1 Help Now