Reputation: 38180
I read that one cannot use ASP.NET MVC with Server Control which have ViewState including TextBox ?
http://forums.asp.net/t/1216834.aspx
Server controls that do not require ViewState to fully function will work in MVC, but anything that requires PostBack to work properly will not.
So bindable, read-only controls like the Repeater will work, but input controls like the DropDownList and TextBox will not.
What should I use then if I cannot even use TextBox ?
Upvotes: 1
Views: 407
Reputation: 42246
ASP.NET and ASP.NET MVC both use a backend coding convention to render HTML markup. In ASP.NET the convention is to use Control classes, and in ASP.NET MVC the convention is to use HtmlHelper
extension methods.
The TextBox ASP.NET Control with the following ASP.NET markup
<asp:TextBox id="sample_tbx" Text="Sample Default Value" runat="server" />
renders the following HTML markup
<input type="text" name="sample_tbx" id="sample_tbx" value="Sample Default Value" />
To get the same result with an HtmlHelper
extension method in an MVC View, the convention is to use the TextBox()
extension method. For example,
<%= Html.TextBox("sample_tbx", "Sample Default Value") %>
In either ASP.NET or ASP.NET MVC, html markup can be written inline. So, simply writing
<input type="text" name="sample_tbx" id="sample_tbx" value="Sample Default Value" />
is valid for either ASP.NET WebForms or ASP.NET MVC.
Upvotes: 1
Reputation: 190897
You just use standard HTML input fields or HTML Helpers.
Upvotes: 3