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

推荐订阅源

C
Check Point Blog
Y
Y Combinator Blog
GbyAI
GbyAI
Microsoft Azure Blog
Microsoft Azure Blog
Martin Fowler
Martin Fowler
博客园_首页
大猫的无限游戏
大猫的无限游戏
美团技术团队
S
SegmentFault 最新的问题
T
The Blog of Author Tim Ferriss
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
MyScale Blog
MyScale Blog
小众软件
小众软件
Vercel News
Vercel News
阮一峰的网络日志
阮一峰的网络日志
N
Netflix TechBlog - Medium
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
量子位
博客园 - 【当耐特】
J
Java Code Geeks
F
Fortinet All Blogs
宝玉的分享
宝玉的分享
Stack Overflow Blog
Stack Overflow 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