0

I have a page in html format and I want to change that into the razor syntax. Here is the code:

<label class="class1" for="textinput">
    <button class="class2" href="#abc">Send</button>&nbsp;To
</label>
Amirhossein Mehrvarzi
  • 18,024
  • 7
  • 45
  • 70
Divya
  • 979
  • 3
  • 13
  • 18

1 Answers1

0

Simply use Razor HtmlHelpers:

@Html.LableFor(model => model.textinput)
//or @Html.Lable("textinput")
<button class="class2" <--!href="#abc"-->>Send</button>&nbsp;To
//we don't have 'href' attribute in button tag
@html.ActionLink("Action", "Controller", null/*routing values*/)

do you wanna have a Button inside Label? To understand more read this.

Edit: According to W3, The label itself may be positioned before, after or around the associated control. See Should I put input tag inside label tag? and Should we put inside ? for more understanding. But, If you really wanna do that, You cant use @Html.Label or @Html.LabelFor, because of non potentiality of putting element inside it via Razor Syntax.

Community
  • 1
  • 1
Amirhossein Mehrvarzi
  • 18,024
  • 7
  • 45
  • 70