惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
小众软件
小众软件
GbyAI
GbyAI
酷 壳 – CoolShell
酷 壳 – CoolShell
F
Fortinet All Blogs
博客园 - 三生石上(FineUI控件)
B
Blog
量子位
B
Blog RSS Feed
Vercel News
Vercel News
Blog — PlanetScale
Blog — PlanetScale
Last Week in AI
Last Week in AI
博客园 - 叶小钗
MongoDB | Blog
MongoDB | Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
爱范儿
爱范儿
Jina AI
Jina AI
C
Check Point Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
IT之家
IT之家
H
Hackread – Cybersecurity News, Data Breaches, AI and More
云风的 BLOG
云风的 BLOG

博客园 - Leon916

SVN Client Gap Buffer ORA-1034 ORACLE not available (转) 关于命名管道 Socket 异步调用 .动态调用WebService(C#) C# weakreference About IL, ILGenerator Update 语句 VS2008的XML编辑器没了( 装) OpCodes (转)全面讲解Oracle查询用户表空间 [译文]从底层角度看ASP.NET-A low-level Look at the ASP.NET Architecture ( 转) Object Builder Application Block jquery Introducing “Razor” – a new view engine for ASP.NET 命名参数(转) (转)HTTP POST GET 本质区别详解 Asp.Net MVC
TextBox & TextBoxFor
Leon916 · 2012-09-04 · via 博客园 - Leon916

http://stackoverflow.com/questions/5119373/difference-between-html-textbox-and-html-textboxfor

Html.TextBox is not strongly typed and it doesn't require a strongly typed view meaning that you can hardcode whatever name you want as first argument and provide it a value:

<%= Html.TextBox("foo", "some value") %>

You can set some value in the ViewData dictionary inside the controller action and the helper will use this value when rendering the textbox (ViewData["foo"] = "bar").

Html.TextBoxFor is requires a strongly typed view and uses the view model:

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

The helper will use the lambda expression to infer the name and the value of the view model passed to the view.

And because it is a good practice to use strongly typed views and view models you should always use the Html.TextBoxFor helper.

http://developer.51cto.com/art/201001/179015.htm