tag:blogger.com,1999:blog-1179473529409580853.post360667860828921155..comments2024-02-02T10:16:36.942+01:00Comments on Erratic software development: Asp.net MVC model binding to ListRoberthttp://www.blogger.com/profile/16847404771942651365noreply@blogger.comBlogger9125tag:blogger.com,1999:blog-1179473529409580853.post-17892595832983257412012-07-18T10:24:38.921+02:002012-07-18T10:24:38.921+02:00Hi Robert,
How did you deal with validation error...Hi Robert,<br /><br />How did you deal with validation errors? <br /><br />Let's say you have business validation happening in your controller, something that would go:<br />"user x is not allowed to send a message to recipient y".<br /><br />Then what you may want to display is a validation message next to the wrong recipient. The problem is, the default mvc mechanism for retrieving attempted values would not work because the recipient list is dynamically created on the client side. How did you solve this?<br /><br />Thanks, nice post by the wayNicolashttps://www.blogger.com/profile/16721017603101964246noreply@blogger.comtag:blogger.com,1999:blog-1179473529409580853.post-48838794313478102452012-02-25T14:22:46.473+01:002012-02-25T14:22:46.473+01:00Hi Yasir. Can you be a bit more specific what are ...Hi Yasir. Can you be a bit more specific what are the problems that you're facing? It would be easier for me to provide some more direct and useful code.Roberthttps://www.blogger.com/profile/16847404771942651365noreply@blogger.comtag:blogger.com,1999:blog-1179473529409580853.post-42576079026572515192012-02-25T10:36:58.179+01:002012-02-25T10:36:58.179+01:00Hello Robert, for my application, I need to implem...Hello Robert, for my application, I need to implement something very similar to your use case using MVC and jQuery. Can you please provide me the complete code that you wrote? In case you can't have the code here, you can mail me the code at yasir.m.syed at gmail.com.yasirhttps://www.blogger.com/profile/06132863345071583274noreply@blogger.comtag:blogger.com,1999:blog-1179473529409580853.post-40811173896839268152012-01-16T21:20:46.367+01:002012-01-16T21:20:46.367+01:00I haven't done anything in this regard, but se...I haven't done anything in this regard, but searching the internet for <i> display modes webforms mobile</i> should give you some relevant results.<br /><br />That's the best advice I can give you at the moment in this regard.Roberthttps://www.blogger.com/profile/16847404771942651365noreply@blogger.comtag:blogger.com,1999:blog-1179473529409580853.post-3100582956379299382012-01-16T20:32:54.416+01:002012-01-16T20:32:54.416+01:00Thanks a lot Robert,
You gave a more detailed expl...Thanks a lot Robert,<br />You gave a more detailed explanation than I expected.<br /><br />That web page is already implemented using ASP.NET web form, but intention of moving towards MVC is based on new upcoming features which MVC 4 promises to support of mobile dev. <br />I need to show same page on mobile devices as well.<br /><br />But now I can see that in this particular case web forms give me much less problems than MVC for solving this task (conducting a survey).<br /><br />The only thing which needs to be done is manage with showing survey on mobile browsers (I mean it should take into account screen resolution, magnification of controls if needed..etc)<br /><br />Could you suggest any approach/.net solution for mobile devices?<br /><br />Thanks,<br />AleksAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1179473529409580853.post-53397163233348996512012-01-16T13:42:48.688+01:002012-01-16T13:42:48.688+01:00How I would go about this problem...
1. Common pa...How I would go about this problem...<br /><br />1. Common parent class <i>QuestionBase</i><br />2. As many partial views as there are question types each responsible of displaying that particular question type form.<br />3. Parent view would be of model type <i>IList<QuestionBase></i> or <i>IEnumerable<QuestionBase></i> and would iterate through all questions and <i>RenderPartial</i> for each based on their actual type.<br />4. Every partial question would have a reference to a particular javascript function that would be able to collect question data into a javascript object.<br />5. On submit there would be a javascript function that would call individual question functions and generate an array of questions.<br />6. Use my other plugin <i>toDictionary</i> to convert this array of objects (<a href="http://erraticdev.blogspot.com/2010/12/sending-complex-json-objects-to-aspnet.html" rel="nofollow">plugin link here</a>).<br /><br /><b>Additional directions</b><br /><br />1. Stay away from Asp.net web forms server controls (like <i>RadioButtonList</i>) in Asp.net MVC. It will make your life much easier. You should either decide to write your application purely in MVC or purely in WebForms. Don't mix and match.<br />2. It would be a bit more complicated to model bind to concrete <i>QuestionBase</i> inherited objects but using a separate POST object classes could do the trick. Using additional action filters or model binders is an additional step to use to automate this even further.<br /><br />Hope this helps.Roberthttps://www.blogger.com/profile/16847404771942651365noreply@blogger.comtag:blogger.com,1999:blog-1179473529409580853.post-38012942687888154572012-01-16T13:23:51.996+01:002012-01-16T13:23:51.996+01:00Hi Robert,
The example your showed above is very ...Hi Robert, <br />The example your showed above is very close to what I need to implement:<br />Survey Form<br /> Queqsion 1 Which color you like more ?<br /> RadioButton * Blue<br /> RadioButton * Red<br /> RadioButton * Green<br /> <br /> Queqsion 2 Check, check, how many days month can have?<br /> CheckBox 28<br /> CheckBox 11<br /> CheckBox 31<br /> CheckBox 18<br /> <br /> Question 3 What's your favorite song?<br /> TextBox: ……..(any text)<br /> <br /> < Previous Page (button) Next Page> (button)<br /> <br /> <br /> <br /> I need to built questions (number is know only in runtime), with<br /> diffident type of answers (controls) (it is also known only in runtime),<br /> and save answers, loading next (page) batch of Questions<br /> <br /><br /> But I can't get how to build and show complex type of controls like RadioButtonList on the page (using MVC 3 and preferably Razor view engine)<br /> <br /> I would be very grateful, if you cold show me direction (example) - how to solve this problem.<br /> <br /> Thanks, <br /> AleksAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1179473529409580853.post-20215687899858149072011-12-12T16:06:32.524+01:002011-12-12T16:06:32.524+01:00@J@F: Which part of code makes you most problems? ...<b>@J@F</b>: Which part of code makes you most problems? My solution is very problem specific and most likely wouldn't be too helpful for you. The outlined functionality is completely relevant. But if you can point out the main problem I may be able to help you better...Roberthttps://www.blogger.com/profile/16847404771942651365noreply@blogger.comtag:blogger.com,1999:blog-1179473529409580853.post-16828171985936925452011-12-12T15:41:40.225+01:002011-12-12T15:41:40.225+01:00can you post the code sample pleasecan you post the code sample pleaseAnonymousnoreply@blogger.com