zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    jsp Ajax请求(返回xml数据类型)
    springboot整合mybatis
    springboot使用jdbcTemplate案例
    springboot使用jpa案例
    使用SpringBoot访问jsp页面
    SpringBoot使用thymeleaf案例
    SpringBoot
    Dobbox
    Spring Jpa
    SSM整合Dubbo登陆案例
  • 原文地址:https://www.cnblogs.com/dupeng0811/p/2527045.html
Copyright © 2011-2022 走看看