Making forms in MVC views with Html.BeginForm()

.BeginForm() extension method will create a form tag thus associating form level methods to the page.

Example

@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>AfterLogin</title>
</head>
<body>
    <div>
        @using (Html.BeginForm())
        {
            @Html.TextBox("Name");
            <br />

            @Html.Password("Password");
            <br />
            
            <input type="submit" value="Sign In">
        }
    </div>
</body>
</html>
Share

You may also like...