Add styling to all @Html.ActionLink from css class -


I know that I am using a class to add an HTML link, which single Functional at one time:

  @ html.ActionLink ("add", "updatenot", "notes", new {id = 0, type = (int ), The "{@ class =" BTN BTN-primary icon-edit "}, empty)   

However,

is there a way to define a class (Add a style to all divs in a very CSS file like:

  div {color: red;}; ^ ^ | | This will work on * all * divs  <         

I can just write

/ Pre>

There will be color: red included


automatically without having to go to each action link and @ class = "myClass" / Code>


for example

define the class for the nonlinear link One way to do this: To add style for all button instances:

  input [type = "button"] {background color: red; }   

What I could do with something like:

  input [type = "actionlink"] {// Akshnlink all projects Style}}   

and therefore all can be written as aplication:

@html. Exynalink ("Action", "Controller")

And automatically include the style given in my CSS file?


I do not do it the first way to do, but I've already defined as ~ 100 made, no class, and copy and paste:

  class = "myClass"    

Akshnlink just generate common anchor, then You can type:

  a {color: red; }   

But just to get ActionLinks you will need to call them through a square or container.

Also take a better way to custom Aekshnlink inside a default class to it and using this class you can make your selection, as you will use this new custom Akshnlink and paste Class No need to copy

  public static class Linkakstenshn {public static MvcHtmlString MyActionLink (this HtmlHelper html helper, string link text string action, string controller) {var currentAction = htmlHelper.ViewContext.RouteData.GetRequiredString ( "Action" ); Var current controller = htmlHelper.ViewContext.RouteData.GetRequiredString ("controller"); If (Action == Current Actions & Controllers == Current Controller) {var anchor = new TagBuilder ("a"); Anchor. Attribute ["href"] = "#"; Anchor.AddCssClass ("currentPageCSS"); Anchor.SetInnerText (LinkText); Return MvcHtmlString.Create (anchor.ToString ()); } Return htmlHelper.ActionLink (linkText, Action, Controller); }}% ​​= HTML.MyActionLink ("Hello Foo", "Index", "Home")%> & Lt;% = HTML.MyActionLink ("Hello Bar", "About", "Home")%>   

code has been copied

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

python - 'NoneType' object is not callable using 'find_all' in BeautifulSoup -