如何在 ASP.NET MVC2 Web 应用程序中创建文本框(从工具箱)?

发布于 2024-10-17 19:19:02 字数 81 浏览 3 评论 0 原文

工具箱说该组中没有可用的控件?

我必须在 asp.net mvc2 Web 应用程序中创建一个文本框?

请解释一下。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

吐个泡泡 2024-10-24 19:19:02

工具箱是您可能从 WebForms 开发中学到的习惯,但在 ASP.NET MVC 中不再适用。在 ASP.NET MVC 中,您编写代码。要生成文本框(),您可以使用 TextBoxFor HTML 帮助器:

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

或者如果您没有强类型视图(尽管如果您想要正确设计的 MVC 应用程序,则应该这样做)

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

所以告别服务器控件和工具箱并向 ASP.NET MVC 打个招呼。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文