0

In my MVC application, I have used @Html.ActionLink. I have set their styles to display them like a button, but the problem is that there are stome styles for a, a:link, etc (I mean, all anchor behaviors) in the CSS file, and that is why the links on @Html.ActionLink appears like links, and not plain text. Any idea to get rid of all anchor behavior for those particular @Html.Actionlink controls?

mipe34
  • 5,596
  • 3
  • 26
  • 38
Nirman
  • 6,715
  • 19
  • 72
  • 139
  • `@Html.Actionlink` renderes just plain HTML anchor tag. So I think you could achieve your task by playing with CSS styles. There is also overload of `@Html.ActionLink` where you can set html attributes like style and class. – mipe34 Jan 11 '13 at 11:49

1 Answers1

1

Is using jQuery an option? You could write a function to remove the css from each link on startup.

$(document).ready(function() {
    // to clear css from a specific item
    $("#your-link-id").removeClass();

    // to clear css from a bunch of links
    $("your-selector a").each(function() {
        $(this).removeClass();
    });
});

Or you could create additional css classes that override the styles on your a tags.

<style type="text/css">
    .whatever { background-color:black !important; }
</style>

@Html.ActionLink("MyAction", "MyController", new { @class = "whatever" })

hawkke
  • 4,242
  • 1
  • 27
  • 23