Search code examples
cssasp.netasp.net-mvchtml-helpersemantic-ui

Using Html.BeginForm and Semantic UI


When I use Html.BeginForm, the semantic UI will runs off and uses the classic UI.

How do I get this fixed?

@using (Html.BeginForm())
{
<div id="addRestaurant">
    <form class="ui form">
        <div class="required field">
            <label for="resName">Restaurant Name</label>
            <input type="text" name="model.RestaurantName" id="RestaurantName"/>
        </div>
...
</div>
}

Before using Html.BeginForm enter image description here

After using Html.BeginForm enter image description here


Solution

  • Apply the class to the mvc form

    <div id="addRestaurant">
    @using (Html.BeginForm("ActionName","ControllerName", method: FormMethod.Post, htmlAttributes: new { @class="ui form"} )) {
    
            <div class="required field">
                <label for="resName">Restaurant Name</label>
                <input type="text" name="model.RestaurantName" id="RestaurantName"/>
            </div>
    ...
    
    }
    </div>