< asp:TextBox>VS<输入类型=“文本">VS Html.TextBox [英] <asp:TextBox> Vs <input type="text"> Vs Html.TextBox
问题描述
我正在asp.net应用程序中工作,添加了诸如表单元素,验证和从DB填充数据之类的功能.
I am working in asp.net application, adding functionalities like form elements, validation and populating data from DB.
-
我可以使用ASP:控件,但我想知道是否可以使用
HTML.TextBox
或< input type ="text">
如果我可以使用< input type ="text"
或 Html.TextBox
,则使用它们与使用
If I can use <input type="text"
or Html.TextBox
what are the pros and cons of using them versus using
推荐答案
忘记ASP.NET MVC中的服务器端控件.在ASP.NET MVC中,所有包含 runat ="server"
的内容都是很大的 NO .无论如何都不会在Razor中工作.没有优缺点.服务器端控件绝对不能使用,因此没有可比较的东西.只需使用HTML帮助程序,例如 Html.EditorFor
和 Html.TextBoxFor
.
Forget about server side controls in ASP.NET MVC. Everything containing runat="server"
is a big NO in ASP.NET MVC. Won't work in Razor anyways. There are no pros and cons. Server side controls should never be used so there's nothing to compare. Simply use HTML helpers such as Html.EditorFor
and Html.TextBoxFor
.
这篇关于< asp:TextBox>VS<输入类型=“文本">VS Html.TextBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!