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

推荐订阅源

月光博客
月光博客
有赞技术团队
有赞技术团队
S
SegmentFault 最新的问题
宝玉的分享
宝玉的分享
量子位
小众软件
小众软件
The Cloudflare Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
G
Google Developers Blog
博客园 - 叶小钗
H
Help Net Security
Jina AI
Jina AI
Y
Y Combinator Blog
Last Week in AI
Last Week in AI
GbyAI
GbyAI
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Apple Machine Learning Research
Apple Machine Learning Research
MyScale Blog
MyScale Blog
T
Tailwind CSS Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Vercel News
Vercel News

博客园 - 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