Replace Hyperlink column with a Button

If you have ever had to deal with unruly hyperlink columns in a List, you know they can be a mess.  What I’ve done is add a button to a column using SharePoint Designer. Then set the buttons path equal to the unruly hyperlink url.

To start this example I created a List then added a Hyperlink column named LongURL.

From the Ribbon click on Edit List to open SharePoint Designer.

Once SharePoint Designer opens, click on All Items in the Views section.

In this step we are going to add a column to the table in the Web Part.  I right clicked in the LongURL column, selected Insert, then Column to the Right.

With the cursor in the row of the new column, click on the Design tab at the top of screen, click on Insert Control, then Form Action Button.

Next we will want to set two of the buttons properties.  Click on the button, the Tag Properties for the button should now be displayed on the right side of SharePoint Designer.  In the Attributes section, you can set the text that appears on the button.  This can be static text or text that is bound to an item in the row.

While still in the Tag Properties, scroll down to Events and look for onclick, this is where we are setting the hyperlink value of the button.   In the onclick field enter:  window.location.href='{@LongURL}’

Now, click save and return to your browser and refresh the page.  You should now see the newly added button.

Safe to assume you want to remove the LongURL column?  Go back to SharePoint Designer.  Click in the column that displays LongURL.  Now, right click, select Delete, then Delete Columns.  Click save, and return to your browser and refresh the page.

Your page should now look like this:

Let me know

8 thoughts on “Replace Hyperlink column with a Button

  1. Hey thanks for providing such useful information.
    Keep up th good work ahead.
    Best of luck.

  2. I really liked the way this method looked, but the buttons end up with onclick=”window.location.href=”” in the tag. I tried passing the value of other fields in the record and the result is always the same.

    Any ideas?

  3. look in the code window and make sure the input button “code” is correct.

    <input name="Button1" type="button" value="{@LongURL.desc}" onclick="window.location.href='{@LongURL}'" />
    

    When walking through this post, I noticed my single quote was messed up in SharePoint Designer. When I corrected the quote error, my ‘{@LongURL}’ turned green.

    let me know if this helps.

  4. I liked the look of this as it was exactly what I wanted.

    Having a problem though.
    I have a column created which is a url column same as yours but called AssetURL and when you click on the link it goes to the sound file in the link. I have created a button called Play Evidence.

    I followed your example to the letter but when I click on the link button it does not go to the sound file but to the root of the audio library and the link in the browser window is not the same as the link displayed in the field AssetURL. It looks like {@AssetURL} is not actually returning the url?!

    I tried but still no joy (:-()

Leave a Reply

Your email address will not be published. Required fields are marked *