Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.Net-MVC: How to style <%=Html.ActionLink()%> with Css?

Here's a piece of my HTML code

<div id = "mydiv">
    <% = Html.ActionLink("Some Text","SomeAction")%>
</div>

I'd like to style it in white so that it doesn't conflict with the background, which is also blue. So I did this:

#mydiv {background-color:blue;} 
#mydiv a:link { color:white}

But, it doesn't work -- the color it's still blue. How can I do it? Maybe, I just did not write well the selectors.

Thanks for helping.

like image 676
Richard77 Avatar asked Feb 11 '10 12:02

Richard77


People also ask

How do I change the color of an ActionLink in HTML?

@Html. ActionLink("name", "Action", "Controler", new { id= sentId, Style = "color:White" }, null);

What is the difference between using URL action and HTML ActionLink in a view?

Yes, there is a difference. Html. ActionLink generates an <a href=".."></a> tag whereas Url. Action returns only an url.

What is HTML ActionLink ()?

ActionLink(HtmlHelper, String, String, String, String, String, String, Object, Object) Returns an anchor element (a element) for the specified link text, action, controller, protocol, host name, URL fragment, route values, and HTML attributes.

How do you pass an ActionLink model?

ActionLink is rendered as an HTML Anchor Tag (HyperLink) and hence it produces a GET request to the Controller's Action method which cannot be used to send Model data (object). Hence in order to pass (send) Model data (object) from View to Controller using @Html.


2 Answers

#mydiv a { color:white; }
like image 59
Darin Dimitrov Avatar answered Sep 25 '22 19:09

Darin Dimitrov


Maybe

<%=Html.ActionLink("Text","Act","Ctrl",new {@style="color:white;"}) %>
like image 33
luke Avatar answered Sep 26 '22 19:09

luke