How do I set the default text (in a create view) for a TextBoxFor element:
@Html.TextBoxFor(Function(model) model.QualityM1s, New With {Key .text="0"})
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Not exactly sure what you mean by default text. If you want to preinitialize the textbox with some value you could use a normal textbox:
and then you could set the corresponding view model property to the default value inside your controller action just before passing the model to the view:
The TextBoxFor helper will then use the value of your model property to fill the corresponding textbox.
If you want to apply a watermark effect you have 2 possibilities:
Use the new HTML 5 placeholder attribute (this obviously assumes that the client browser supports it):
Use javascript. For example there are many jQuery watermark plugins.