ASP.NET-MVC2 Preview 1: Are There Any Breaking Changes?

后端 未结 4 555
长情又很酷
长情又很酷 2020-12-12 07:23
  1. I was following Steven Sanderson\'s \'Pro ASP.NET MVC Framework\' book.
  2. On page 132, in accordance with the author\'s recommendation, I downloaded the ASP.NET
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-12 07:42

    Another change is when dealing with form lists from your ViewModel.

    For example in MVC 1.0 if you had a list of objects IList< MyObject > displayed in your View

    <% for (int i = 0; i < Model.Length; i++) { %>
        <%= Html.TextBox("MyObject[" + i + "].FirstName") %>
        <%= Html.TextBox("MyObject[" + i + "].LastName") %>
    <% } %>
    

    The input boxes would be rendered as

    
    

    Note: id = MyObject[0]_FirstName and name = MyObject[0].FirstName

    However, in MVC 2.0 they are rendered as

    
    

    Note: id = MyObject_[0]__FirstName and name = MyObject[0].FirstName

    This broke some jquery I was using to manipulate my table data. Notice the single and double underscores in the id.

提交回复
热议问题