html.beginform html attributes class

Jak
Jak
Member
858 Points
132 Posts

Hi,

How to add css class in the mvc form using Html.beginform() ?

Views: 10206
Total Answered: 1
Total Marked As Answer: 0
Posted On: 26-Sep-2015 08:59

Share:   fb twitter linkedin
Answers
Rahul Maurya
Rahul M...
Teacher
4822 Points
23 Posts
         

Hi Jak,

You can pass argument as Html Attribute object as:

Razor Syntax:

@using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post, new{ @class= "classname"})) {

}

Rendered form as:

<form action="/ControllerName/ActionName" class="classname" method="post"></form>

ASPX Syntax:

<%using (Html.BeginForm("ActionName", "ControllerName", FormMethod.Post, new{ @class= "classname"})) { %>

<%}%>
Posted On: 05-Dec-2015 06:43
 Log In to Chat