How to format mvc helpers according to my Bootstrap layout?

Asked

Viewed 94 times

1

I am trying in various ways to adjust the layout according to the Helpers

          <!-- rightpanel3  -->
            <div data-role="panel" id="opcoesusuario" data-position="right" data-display="overlay" data-theme="a">


            <a  class="ui-btn ui-mini" data-rel="close" data-transition="flip"  data-role="button" >@Html.ActionLink("Perguntas ","index","PerguntasRespondidas")</a>




      </div><!-- /rightpanel3 -->   
  • I did it this way, it worked! <a href="/Questionsrespondidas" class="ui-btn ui-mini" data-rel="close" data-Transition="flip" data-role="button" >Completed Questions</a>

1 answer

0

You can pass the parameters as htmlAttributes.

To do this, use the overload @Html.ActionLink("texto ancora", "Action", "Controller", new { htmlAtributtes })

Example:

@Html.ActionLink("Perguntas", "Index", "PerguntasRespondidas", new { @class="ui-btn ui-mini", data_rel="close", data_transition="flip",  data_role="button"  })

Remarks:

  1. The word class is a reserved word. So when you pass a css class like htmlAttribute use the syntax @class="sua-classe" MVC will know how to render it in the View.

  2. htmlAttributes is a object for the compiler, so the name of its property cannot count some characters. such as the hyphen. Hence the attributes data- html should be written as data_. Again MVC does its part and renders as data-

Soon the above example would be rendered as:

<a class="ui-btn ui-mini" data-rel="close" data-role="button" data-transition="flip" href="/PerguntasRespondidas/Index/">Perguntas</a>

Example: https://dotnetfiddle.net/KWLSeF

Browser other questions tagged

You are not signed in. Login or sign up in order to post.