Thoughts from Dan Miser RSS 2.0
# Tuesday, February 23, 2010
I use list binding in my ASP.NET MVC applications in several places. When it works, it is truly magnificent. When it doesn't, it's just maddening. Here's a quick heads up for those of you that use list binding in MVC. You would expect the following 2 lines to render the same HTML, but they don't. To get list binding to work, you need the HTML to read something like this (I'm just listing the attributes in question here):


<input name="Results[0].Score" />

The old TextBox helper works fine, since you're assigning the name attribute:


Html.TextBox("Results["+id+"].Score", Model.Score)

This code, however:


Html.TextBoxFor(r => r.Score, new { name = "Results[" + id + "].Score" })

produces the following output, which means the Score property won't get bound properly.


<input name="Score" />

The problem is that in the TextBoxFor code, the name attribute is ignored. To be more precise, the custom name is added, but the attribute is then replaced by the name derived from the model.

Tuesday, February 23, 2010 10:12:13 PM (Central Standard Time, UTC-06:00)  #    Comments [3] -
.NET | ALT.NET | ASP.NET MVC
Wednesday, March 17, 2010 4:42:44 PM (Central Standard Time, UTC-06:00)
Don't you understand that this is correct time to get the business loans, which would make your dreams come true.
Saturday, March 20, 2010 8:11:30 AM (Central Standard Time, UTC-06:00)
Even buy thesis services could not perform such kind of supreme dissertation idea connecting with this good post and possibly, you work especially for dissertation writing services. In this situation I could buy a dissertation from your company straight off.
Wednesday, March 24, 2010 3:10:01 PM (Central Standard Time, UTC-06:00)
I wish I had read more about this custom papers earlier. I had used some other term papers but that was beyond my aspect. Custom essay company is your arcanum.
Comments are closed.
Navigation
Archive
<February 2012>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
26272829123
45678910
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2012
Dan Miser
Sign In
Statistics
Total Posts: 375
This Year: 3
This Month: 0
This Week: 0
Comments: 654
Themes
Pick a theme:
All Content © 2012, Dan Miser
DasBlog theme 'Business' created by Christoph De Baene (delarou)