<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Part 6: Using Data Annotations for Model Validation</title><link>http://asp.net</link><pubDate>Sat, 08 Dec 2012 22:58:39 GMT</pubDate><generator>umbraco</generator><description>Comments for Part 6: Using Data Annotations for Model Validation</description><language>en</language><atom:link href="http://asp.net/rss/comments/27630" rel="self" type="application/rss+xml" /><item><title>Comment Posted by myshadow</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Tue, 13 Jul 2010 22:19:33 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-000000009439</guid><description><![CDATA[ <p>Thanks very much for this tutorial. It was a bit frustrating at times to work through it, but most definitely worth the effort. Learned a lot!</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/myshadow.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by sasiatia</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Tue, 04 Jan 2011 09:55:12 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000011409</guid><description><![CDATA[ <p>:) I&#39;m happy</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/sasiatia.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by CFonseca</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Mon, 18 Apr 2011 14:15:46 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000012855</guid><description><![CDATA[ <p>I was having trouble with the decimal separator for the Price field, but found the solution and i post it here for people having the same problem.</p><p></p><p>The problem i was having was related with having the comma or a point as the decimal separator. I discovered that putting a globalization statment in the web.config for the aplication solved the problem.</p><p></p><p>&lt;system.web&gt;</p><p>    &lt;globalization culture =&quot;en-US&quot; /&gt;</p><p>.</p><p>.</p><p>.</p><p></p><p>Hope migh help someone</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/CFonseca.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by arrow3215</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Sun, 01 May 2011 07:39:30 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013044</guid><description><![CDATA[ <p>I found, that due to the </p><p> [Bind(Exclude = &quot;AlbumId&quot;)]</p><p> in the Album model the  HTTPOST - &quot;Edit&quot; - Action not working anymore.</p><p>Adding </p><p></p><p>    public ActionResult Edit(Album album, int id)</p><p>        {</p><p>            if (ModelState.IsValid)</p><p>            {</p><p>                album.AlbumId = id;</p><p></p><p>helped.</p><p></p><p></p><p></p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/arrow3215.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by rob grainger</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Thu, 05 May 2011 19:20:13 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013083</guid><description><![CDATA[ <p>@arrow3215</p><p>Thanks for posting that - may have saved me some work.</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/rob%20grainger.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by inmykingdom</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Sun, 22 May 2011 10:46:32 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013240</guid><description><![CDATA[ <p>I think an explanation on why AlbumId is excluded from the binding model but added as scaffoldcolumn would be interesting. Seeing that it would without this, it&#39;s unclear what the goal is of adding these attributes.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/inmykingdom.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by dtaur</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Fri, 03 Jun 2011 07:44:54 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013377</guid><description><![CDATA[ <p>I&#39;ve found out that AlbumId is 0 on Edit POST and it fails. Now I see I&#39;m not the only one. I agree with inmykindom that it would be nice to know what was the reason of putting [Bind(Exclude = &quot;AlbumId&quot;)] attribute.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/dtaur.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by darkrider23</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Fri, 03 Jun 2011 08:50:18 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013378</guid><description><![CDATA[ <p>I think the reason AlbumId is exluded is because you could potentially change the AlbumId through the url</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/darkrider23.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by KimMogensen</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Fri, 22 Jul 2011 15:26:44 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000013814</guid><description><![CDATA[ <p>@arrow3215: also thanks from me...</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/KimMogensen.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by Fermat</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Thu, 01 Sep 2011 07:04:39 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014100</guid><description><![CDATA[ <p>isn&#39;t it a way to mix Model stuff with View stuff? I don&#39;t think is good to have some &#39;invasive&#39; properties there (like DisplayMessage)... Just only think in localization issues... </p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/Fermat.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by garyseven</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Wed, 21 Sep 2011 10:10:43 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014233</guid><description><![CDATA[ <p>arrow3215, thanks for the fix!</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/garyseven.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by samarmir</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Thu, 06 Oct 2011 15:23:14 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014349</guid><description><![CDATA[ <p>Thanks again for another part. </p><p>And thanks to the users that are correcting the errors in this part and explaining the not so clear things</p><p></p><p>Mohammad</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/samarmir.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by TheGDizzo</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Wed, 02 Nov 2011 13:57:43 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014547</guid><description><![CDATA[ <p>NOTE: I don&#39;t know if it&#39;s because of updates to EF 4.1 or the model binder... but including the Data Annotation of:</p><p></p><p>[Bind(Exclude = &quot;AlbumId&quot;)]</p><p></p><p>In Models\Album.cs ended-up causing the value of AlbumID to be returned as 0 (zero) in the Album Entity returned in the HTTPPOST&#39;d Edit method in the StoreManagerController.cs in the next tutorial.  Which threw up an exception. </p><p></p><p>What I am not  100% sure on is if this behavior started when I changed my connectionString&#39;s in web.config such that VWD2010 Express would now be storing the data onto my SQL Server 2008 R2 rather than SQl Compact 4.0.</p><p></p><p>The other goofy issue I&#39;m experiencing, which might also be related to now using 2008 R2 - rather than - Sql Server Compact 4.0... is that Album.Price amounts are only getting stored as whole dollar amounts.  Even when I tried to go directly into SSMS and execute an UPDATE statement on the record directly... which showed the 1 rows affected.. when I would go back to another open query showing the top 1000 rows... when I would re-execute that query I could see where I updated the Title text... (both Price and Title were updated within the same update statement to provide me a visual tattle-tale) but the Price amount was still showing as a whole dollar figure??</p><p></p><p>Can somebody tell me if this is happening because this is VWD2010 &gt;&gt;&gt;EXPRESS&lt;&lt;&lt; perhaps?  Maybe this is Microsoft&#39;s behind-the-scenes way of ensuring developers go purchase the full-blown?? This behaviour is soo bizarre I&#39;m hoping this is the reason why.  </p><p></p><p>P.S. - Please see my comments posted on the next tutorial for more insight and information into these findings.</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/TheGDizzo.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by TheGDizzo</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Wed, 02 Nov 2011 14:04:30 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014548</guid><description><![CDATA[ <p>@arrow315 - Great Minds my friend, Great minds =)  I&#39;m upset with myself that I didn&#39;t think of just taking that &quot;id&quot; value and stuffing it back into the album.AlbumId field.</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/TheGDizzo.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by nightzeus</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Sat, 05 Nov 2011 02:23:55 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014562</guid><description><![CDATA[ <p>@arrow3215</p><p></p><p>Thanks. :) I hate when tutorials send you on a wild goose chase and you end up spending more time debugging the author&#39;s mistake(s).</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/nightzeus.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by Eileithyia</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Tue, 15 Nov 2011 14:55:03 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014634</guid><description><![CDATA[ <p>@nightzeus, yeah the author failed. Thanks to arrow3215. Also there are many part that is very hard to understand.  More explanation would help alot. I kind of want to know the &quot;why&quot;, instead of &quot;how&quot; </p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/Eileithyia.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by michaelpower17</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Thu, 24 Nov 2011 19:32:14 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000014687</guid><description><![CDATA[ <p>Think I somehow pasted code with a different version of jquery than that in my project.</p><p>View/Shared/_Layout.cshtml</p><p></p><p>&lt;!DOCTYPE html&gt;</p><p>&lt;html&gt;</p><p>&lt;head&gt;</p><p>    &lt;title&gt;@ViewBag.Title&lt;/title&gt;</p><p>    &lt;link href=&quot;@Url.Content(&quot;~/Content/Site.css&quot;)&quot;</p><p>rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt;</p><p>    &lt;script src=&quot;@Url.Content(&quot;~/Scripts/jquery-1.4.4.min.js&quot;)&quot;</p><p></p><p>Had to change the last line to jquery-1.5.1.min.js</p><p></p><p>Then it works :)</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/michaelpower17.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by bartowj</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Fri, 01 Jun 2012 16:27:24 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015644</guid><description><![CDATA[ <p>Jon,</p><p></p><p>I have a really simple use case with just one foreign key in a 1 to 0..1 &quot;vertical inheritance&quot; relationship between only two tables with a total of 4 properties/fields in the entire solution  that your tutorial doesn&#39;t address.  Can you provide some insight into how to get this to work.  Do I need to use a ViewModel?</p><p></p><p><a rel="nofollow" href="http://stackoverflow.com/questions/10842741/one-to-one-or-one-to-none-entity-framework-referential-constraint-violation" target="_blank">stackoverflow.com/</a></p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/bartowj.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by Richard Scannell</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Wed, 06 Jun 2012 06:52:41 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015693</guid><description><![CDATA[ <p>Hi Jon, </p><p>How would we implement more complex model validation ? EG date x must be greater than date y, or that the amount entered into the payment field of a shopping cart equals the sum of all items bought, plus shipping &amp; taxes,  minus any discounts..</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/Richard%20Scannell.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by superandi</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Sun, 17 Jun 2012 06:01:17 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000015790</guid><description><![CDATA[ <p>If you want the &quot;,&quot; as a decimal seperator (not using the workaround from CFonseca), have a look at <a rel="nofollow" href="http://www.andreas-reiff.de/2012/06/probleme-mit-mvcmovies-beispiel-validierung-des-preises-mit-dezimalstellen-schlagt-fehl/" target="_blank">www.andreas</a>#comment-409 . It is German, though.. basically, it describes how an application localization can be properly changed (if you don&#39;t do it, client- and serverside validation seem to be different languages/cultures, meaning that both &quot;6.66&quot; adn &quot;6,66&quot; will not be accepted - once by client-side and the other time by server-side).</p><p></p><p>Also, there seemed to be a problem with the &quot;Create&quot;, anyone else noticed? I changed it to DB-generated and everything worked (the AlbumID).</p><p></p><p>[ScaffoldColumn(false)]</p><p>[DatabaseGenerated(System.ComponentModel.DataAnnotations.DatabaseGeneratedOption.Identity)]</p><p>public int AlbumId { get; set; }</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/superandi.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by eradwen</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Wed, 08 Aug 2012 16:28:14 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016137</guid><description><![CDATA[ <p>Thank you @CFonseca for this quick fix and thanks to @arrow3215 for making the edit form work again! I wish the author had explained the purpose of [Bind(Exclude = &quot;AlbumId&quot;)]</p>]]></description><enclosure length="0" type="image/png" url="http://i2.asp.net/avatar/eradwen.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by cmarek</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Sun, 19 Aug 2012 22:34:43 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016212</guid><description><![CDATA[ <p>I got to part 6 in the MvcMusicStore tutorial. Then my data disapeared! I can not seem to recover the data back into my dataBase. I would very much like to finish this tutorial. Any help would be greatly appreciated</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/cmarek.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by cmarek</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Tue, 21 Aug 2012 00:58:20 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016230</guid><description><![CDATA[ <p>Never mind my complaint. I caused the problem myself! As I made my way thru the tutorial I was adding many of my own comments in the code, and somewhere along the way I have corrupted my code. I know this is likely because I decided to start over from scratch but added no comments (too tired too) and now I am having no trouble this second time.</p>]]></description><enclosure length="0" type="image/png" url="http://i1.asp.net/avatar/cmarek.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by scorpio62</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Wed, 05 Dec 2012 07:19:46 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016938</guid><description><![CDATA[ <p>If you are using Visual Studio 2012 with MVC 4, the client side validation still not works,</p><p></p><p>That the client side validation works you have do add following:</p><p></p><p>1) Add with NuGet Package Manager &quot;jQuery Unobtrusive Validation&quot;.</p><p></p><p>2) Add in Views/StoreManager/Create.cshtml following after the &lt;h2&gt;Create&lt;/h2&gt;:</p><p></p><p>&lt;script src=&quot;@Url.Content(&quot;~/Scripts/jquery.validate.min.js&quot;)&quot;&gt;&lt;/script&gt;</p><p>&lt;script src=&quot;@Url.Content(&quot;~/Scripts/jquery.validate.unobtrusive.min.js&quot;)&quot;&gt;&lt;/script&gt;</p><p></p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/scorpio62.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item><item><title>Comment Posted by sabinpradhan</title><link>http://asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-6</link><pubDate>Sat, 08 Dec 2012 22:58:39 GMT</pubDate><guid isPermaLink="false">00000000-0000-0000-0000000016966</guid><description><![CDATA[ <p>Thanks @arrow3215 for solving error of edit action and as other say it will be great if author explained the purpose of [Bind(Exclude = &quot;AlbumId&quot;)]</p>]]></description><enclosure length="0" type="image/png" url="http://i3.asp.net/avatar/sabinpradhan.jpg?forceidenticon=false&amp;dt=635072515200000000&amp;enableAvatar=False&amp;cdn_id=2013-05-10-001" /></item></channel></rss>