I have a problem with a view where a new user can be created. There are default values in the textboxes and I have no idea how to get rid of them.
/edit The register model looks like this:
public class RegisterModel
{
[Required(ErrorMessage = "*")]
[Display(Name = "Naam")]
public string UserName { get; set; }
[Required(ErrorMessage = "*")]
[Display(Name = "E-mailadres")]
public string Email { get; set; }
[Required(ErrorMessage = "*")]
[StringLength(100, ErrorMessage = "Het {0} moet op zijn minst {2} tekens lang zijn.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "wachtwoord")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Bevestig wachtwoord")]
[Compare("Password", ErrorMessage = "De twee wachtwoorden komen niet overeen.")]
public string ConfirmPassword { get; set; }
}
The views looks like this and I want only the text of the @placeholder element in the box.
<fieldset>
<legend>Register new user</legend>
<ol>
<li>
@Html.TextBoxFor(m => m.UserName, new { @class = "form-control", @placeholder = "Volledige naam"})
</li>
<li>
@Html.TextBoxFor(m => m.Email, new { @class = "form-control", @placeholder = "E-mail "})
</li>
<li>
@Html.PasswordFor(m => m.Password, new { @class = "form-control", @placeholder = "Wachtwoord" })
</li>
<li>
@Html.PasswordFor(m => m.ConfirmPassword, new { @class = "form-control", @placeholder = "Bevestig wachtwoord"})
</li>
</ol>
<button type="submit">Register</button>
</fieldset>
Unfortunately, the output looks like this:
(Apologies for the Dutch)
The username where I am currently logged in with (a_random_username) is displayed in the box and the same goes for the password field.
I've tried to place a @Value = "" element in the new {} element of the TextBoxFor and PasswordFor elements with no success. I tried to create an empty RegisterModel in the model and pass it to the view with no success. And I tried to update the default values in the model with no success.
I have absolutely no idea why it automatically fills in my own username and password.
I would be very grateful if someone could release me from this misery and explain to me how I can get my own chosen default value to display in the textboxes.