MVC asp.net VB syntax for default text for TextBoxFor
asp.net, asp.net-mvc, asp.net-mvc-3
Solution
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:
@Html.TextBoxFor(Function(model) model.QualityM1s)
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:
model.QualityM1s = "some default text"
return View(model)
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):
@Html.TextBoxFor(Function(model) model.QualityM1s, New With { Key .placeholder = "some default text"})
Use javascript. For example there are many jQuery watermark plugins.
Problem
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"}) ```