How to create a textbox (from toolbox) in asp.net mvc2 web application?

1.1k views Asked by At

The toolbox says there is no usable control in this group?

I have to create a textbox in asp.net mvc2 web application?

Please explain.

1

There are 1 answers

2
Darin Dimitrov On BEST ANSWER

The toolbox is a habit that you might have learned from WebForms development but which no longer applies in ASP.NET MVC. In ASP.NET MVC you write code. And to generate a textbox (<input type="text" ...) you could use the TextBoxFor HTML helper:

<%= Html.TextBoxFor(x => x.SomeViewModelProperty) %>

or if you don't have a strongly typed view (although you should if you want a properly designed MVC application)

<%= Html.TextBox("SomeViewModelProperty") %>

So say goodbye to server controls and toolboxes and say hello to ASP.NET MVC.