How to inherit a class property in a CSHTML file for a text field and button in ASP.NET MVC4?

I am new to ASP.NET MVC4 with Entity Framework. I need to inherit a property for a text field and a button in a cshtml file. And also I have to assign the value of the text box using the model. Please help me get the property. Thanks in advance.

This is my HTML code:

<input type="text" class="form-control uname" placeholder="Username" />
                    <input type="password" class="form-control pword" placeholder="Password" />
                    <a href="#"><small>Forgot Your Password?</small></a>
                    <button class="btn btn-success btn-block">Sign In</button>
+3
source share
3 answers

Try it...

@Model your model.


@using (Html.BeginForm("YOUR_ACTION", "YOUR_Controller"))
{
<fieldset>
<div class="form-control uname">@Html.LabelFor(model => model.Username)</div>
<div class="form-control uname">@Html.TextBoxFor(model => model.Username)</div>

<div class="form-control pword">@Html.LabelFor(model => model.Password).</div>
<div class="form-control pword">@Html.PasswordFor(model => model.Password)</div>
<br/>
</fieldset>
<a href="#"><small>Forgot Your Password?</small></a>
<input type="Submit" value="Sign In" class="btn btn-success btn-block" />
}
+2
source
             @model SomeModel

             @Html.TextBoxFor(m => m.UserName, new {class="form-control uname",placeholder="Username" />
             <input type="password" class="form-control pword" placeholder="Password" />
             <a href="#"><small>Forgot Your Password?</small></a>
             <button class="btn btn-success btn-block">Sign In</button>

Inherit the model, and then apply the html elements with the model values.

+1
source

@ Html.TextBoxFor (m => m.UserName, new {class = "form-control uname", placeholder = "Username" / "> @ Html.TextboxFor (m => m.UserPAssword, new {class =" class name style ", placeholder =" Password "/">

+1
source

All Articles