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

推荐订阅源

IT之家
IT之家
aimingoo的专栏
aimingoo的专栏
H
Help Net Security
L
LangChain Blog
M
MIT News - Artificial intelligence
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
C
Check Point Blog
P
Proofpoint News Feed
J
Java Code Geeks
大猫的无限游戏
大猫的无限游戏
博客园_首页
Blog — PlanetScale
Blog — PlanetScale
U
Unit 42
I
InfoQ
月光博客
月光博客
爱范儿
爱范儿
Stack Overflow Blog
Stack Overflow Blog
V
Visual Studio Blog
Y
Y Combinator Blog
Microsoft Security Blog
Microsoft Security Blog
博客园 - Franky
D
Docker
B
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