<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>ASP.NET MVC</title><link>http://forums.asp.net/1146.aspx</link><description>Discussions regarding Model-View-Controller (MVC) support in ASP.NET.  &lt;a href="http://forums.asp.net/1215.aspx"&gt;T4MVC subforum&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: View bug in preview 4 (worked fine in preview 3)</title><link>http://forums.asp.net/thread/2560689.aspx</link><pubDate>Fri, 15 Aug 2008 15:24:26 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2560689</guid><dc:creator>Haacked</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2560689.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2560689</wfw:commentRss><description>Ah right, I believe that will change.</description></item><item><title>Re: View bug in preview 4 (worked fine in preview 3)</title><link>http://forums.asp.net/thread/2560093.aspx</link><pubDate>Fri, 15 Aug 2008 09:40:26 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2560093</guid><dc:creator>SteveSanderson</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2560093.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2560093</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;Haacked:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;/p&gt;&lt;p&gt;By the way, you can shorten that to this:&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="dir"&gt;&amp;lt;%=&lt;/span&gt; Html.TextArea(&amp;quot;MyText&amp;quot;)  &lt;span class="dir"&gt;%&amp;gt;&lt;/span&gt;
&lt;/pre&gt;&lt;p&gt;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Not in preview 4 - TextArea() doesn&amp;#39;t have an overload that takes only one parameter. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;Is this something being changed in the next release?&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: View bug in preview 4 (worked fine in preview 3)</title><link>http://forums.asp.net/thread/2559666.aspx</link><pubDate>Fri, 15 Aug 2008 02:49:05 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2559666</guid><dc:creator>Haacked</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2559666.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2559666</wfw:commentRss><description>&lt;p&gt;By the way, you can shorten that to this:&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="dir"&gt;&amp;lt;%=&lt;/span&gt; Html.TextArea(&amp;quot;MyText&amp;quot;)  &lt;span class="dir"&gt;%&amp;gt;&lt;/span&gt;

&lt;/pre&gt;</description></item><item><title>Re: View bug in preview 4 (worked fine in preview 3)</title><link>http://forums.asp.net/thread/2557892.aspx</link><pubDate>Thu, 14 Aug 2008 12:58:04 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2557892</guid><dc:creator>Nullable</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2557892.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2557892</wfw:commentRss><description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/stephenwalther/archive/2008/08/13/asp-net-mvc-tip-32-repopulate-form-fields-with-viewdata-eval.aspx"&gt;http://weblogs.asp.net/stephenwalther/archive/2008/08/13/asp-net-mvc-tip-32-repopulate-form-fields-with-viewdata-eval.aspx&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Re: View bug in preview 4 (worked fine in preview 3)</title><link>http://forums.asp.net/thread/2505476.aspx</link><pubDate>Tue, 22 Jul 2008 10:46:22 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2505476</guid><dc:creator>Luis Abreu</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2505476.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2505476</wfw:commentRss><description>Hello again.

I&amp;#39;m using something similar to the approach I&amp;#39;ve mentioned in my current app. It has increased logic in the controller in order to get the &amp;quot;correct object&amp;quot; that is passed to the viewdata.model property, but I hhaven&amp;#39;t really had any problems with it til now...

I&amp;#39;ll try to reuse your approach to see how it feels like...</description></item><item><title>Re: View bug in preview 4 (worked fine in preview 3)</title><link>http://forums.asp.net/thread/2505469.aspx</link><pubDate>Tue, 22 Jul 2008 10:39:56 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2505469</guid><dc:creator>Sgro</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2505469.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2505469</wfw:commentRss><description>&lt;p&gt;It&amp;#39;s arguable. Though the view is responsible only of showing received data, I&amp;#39;m not so sure that it is not its concern to display the correct data in an ambigous scenario like preserving user input on a failed post. That little &amp;quot;Eval&amp;quot; method saves me from passing each single value back and forth between ViewData dictionary and ViewData.Model, and saves me to write a specific action method to handle failed posts, so in my opinion it&amp;#39;s a good thing.&lt;/p&gt;&lt;p&gt;Think about it: if we couldn&amp;#39;t do that, we would have to pass evetytime all data to the dictionary, even on first request, making ViewData.Model totally useless. In fact, you couldn&amp;#39;t use it in any way.&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: View bug in preview 4 (worked fine in preview 3)</title><link>http://forums.asp.net/thread/2505432.aspx</link><pubDate>Tue, 22 Jul 2008 10:15:58 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2505432</guid><dc:creator>Luis Abreu</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2505432.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2505432</wfw:commentRss><description>Hello again.

yes, I understand that. but when you do that, you&amp;#39;re making your view a little more intelligent than it needs to be. or am I seeing it incorrectly?</description></item><item><title>Re: View bug in preview 4 (worked fine in preview 3)</title><link>http://forums.asp.net/thread/2505410.aspx</link><pubDate>Tue, 22 Jul 2008 10:04:01 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2505410</guid><dc:creator>Sgro</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2505410.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2505410</wfw:commentRss><description>It does, but this is exactly the logic of the ViewData.Eval method that solved the problem.&lt;br /&gt;</description></item><item><title>Re: View bug in preview 4 (worked fine in preview 3)</title><link>http://forums.asp.net/thread/2505264.aspx</link><pubDate>Tue, 22 Jul 2008 09:05:10 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2505264</guid><dc:creator>Luis Abreu</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2505264.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2505264</wfw:commentRss><description>Hello again Matteo.

Ok, so what you&amp;#39;re telling me is that you might end up adding each property two times because you might add an object to the viewdata.model property and then you might have also add an entry to the viewdata dic whose key is the name of the property and in this case the value comes frmo the tempdata property.

is this correct?

if it is, then what I&amp;#39;m saying is that you could change your controller logic so that it only passes the object assign to the viewdata.model. what you must do is make sure that the object you&amp;#39;re passing is correclty filled, which means that in some scenarios you&amp;#39;ll get it from a db and in another you&amp;#39;ll get it from tempdata. In practice this means that you&amp;#39;d probably star by checking the tempdata and if it&amp;#39;s null you need to get the item from somewhere else (probably from the db). does this make sense?</description></item><item><title>Re: View bug in preview 4 (worked fine in preview 3)</title><link>http://forums.asp.net/thread/2504379.aspx</link><pubDate>Mon, 21 Jul 2008 23:30:23 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2504379</guid><dc:creator>Sgro</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2504379.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2504379</wfw:commentRss><description>&lt;p&gt;One little thing before the example: in another post I got the solution. Simple use ViewData.Eval(&amp;quot;MyField&amp;quot;) to get the desired behaviour. Now for the example... &lt;br /&gt;&lt;/p&gt;&lt;p&gt;Here&amp;#39;s a brief example using only 1 field. As for the view:&lt;/p&gt;&lt;p&gt;&amp;lt;%= Html.TextArea(&amp;quot;MyText&amp;quot;, ViewData[&amp;quot;MyText&amp;quot;])&amp;nbsp; %&amp;gt;&lt;/p&gt;&lt;p&gt;In the controller,the actionmethod that is used to create a new record:&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;public ActionResult CreateNew()&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&amp;nbsp;return View(&amp;quot;MyEditView&amp;quot;);&lt;br /&gt;&lt;/p&gt;&lt;p&gt;} &lt;/p&gt;&lt;p&gt;the method for updating an existing record:&lt;/p&gt;&lt;p&gt;public ActionResult EditExisting(String id)&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;//loop through tempdata and assign any values from it to viewdata equivalents, so if we come here by an error in the SaveData method, we still have the user input &lt;br /&gt;&lt;/p&gt;&lt;p&gt;//get the item from LINQ to SQL using the specified ID&lt;/p&gt;&lt;p&gt;ViewData.Model = retreiveditem;&lt;/p&gt;&lt;p&gt;return View(&amp;quot;MyEditView&amp;quot;); &lt;/p&gt;&lt;p&gt;//note: in the perfect scenario, the view will render everything from ViewData.Model except for data present in ViewData dictionary, so user input (if we come from a SaveData error) takes priority on database data &lt;br /&gt;&lt;/p&gt;&lt;p&gt;} &lt;br /&gt;&lt;/p&gt;&lt;p&gt;and the actionmethod called with POST:&lt;/p&gt;&lt;p&gt;public ActionResult SaveData(String MyText)&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&amp;nbsp;//try to save the data, if ok return success view&lt;br /&gt;&lt;/p&gt;&lt;p&gt;//in case of error or invalid user input, memorize MyText in TempData[&amp;quot;MyText&amp;quot;] and redirect to EditExisting method&lt;br /&gt;&lt;/p&gt;&lt;p&gt;} &lt;/p&gt;&lt;p&gt;This example should make it all clear. As stated above, the use of ViewData.Eval(&amp;quot;varname&amp;quot;) solves it, so I think further debate is pointless. &lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: View bug in preview 4 (worked fine in preview 3)</title><link>http://forums.asp.net/thread/2504243.aspx</link><pubDate>Mon, 21 Jul 2008 21:11:03 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2504243</guid><dc:creator>Luis Abreu</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2504243.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2504243</wfw:commentRss><description>Hello again.

there&amp;#39;s one thing I&amp;#39;m not getting: how are you filling the info that is being passed to the view? can you put some demo code for all the scenarios? After seeing it I&amp;#39;ll try to explain what I&amp;#39;m saying...

thanks!</description></item><item><title>Re: View bug in preview 4 (worked fine in preview 3)</title><link>http://forums.asp.net/thread/2503947.aspx</link><pubDate>Mon, 21 Jul 2008 18:43:17 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2503947</guid><dc:creator>Sgro</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2503947.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2503947</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Luis, the reason is clearly explained in my second post. Read it carefully :)&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: View bug in preview 4 (worked fine in preview 3)</title><link>http://forums.asp.net/thread/2503891.aspx</link><pubDate>Mon, 21 Jul 2008 18:12:25 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2503891</guid><dc:creator>Luis Abreu</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2503891.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2503891</wfw:commentRss><description>Hello again guys.

Maybe I&amp;#39;m not following then. In my 2 or 3 experiences with MVC, I always use a strongly typed view. So I always get the the data from the model property (ie, the values passed to control alwas come from the model property). 

Since I really haven&amp;#39;t used any of the previous versions, can any of you guys tell me why it&amp;#39;s so important to make the helpers trye to get a value from the dictionary syntax and then from the model property?  I mean, with the current release, the helpers aren&amp;#39;t doing any &amp;quot;guessing&amp;quot; and this seems fine to me, but maybe I&amp;#39;m wrong...

maybe a specific example would help me understand why the previous behavior is better?

thanks.</description></item><item><title>Re: View bug in preview 4 (worked fine in preview 3)</title><link>http://forums.asp.net/thread/2503655.aspx</link><pubDate>Mon, 21 Jul 2008 16:38:53 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2503655</guid><dc:creator>levib</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2503655.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2503655</wfw:commentRss><description>&lt;p&gt;Luis - I don&amp;#39;t follow.&amp;nbsp; The controller is already responsible for populating the ViewData, and the view is responsible for consuming it.&lt;/p&gt;</description></item><item><title>Re: View bug in preview 4 (worked fine in preview 3)</title><link>http://forums.asp.net/thread/2503256.aspx</link><pubDate>Mon, 21 Jul 2008 14:16:13 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2503256</guid><dc:creator>Luis Abreu</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2503256.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2503256</wfw:commentRss><description>Hello again.

I have a different perspective here...I say that the view and the helpers shouldn&amp;#39;t really do that. They should only receive the data they need to show. what I&amp;#39;m saying is that the controller should always be responsible for passing the *correct* data to the view, ie, you should have a specific view object (I prefer to use a strongly typed approach instead of the dictionary approach) which is filled by the controller with the correct values (which should cover inserts, updates deletes or whatever scenario you have).

In fact, by putting that responsibility in the controller, you can really increment the testing range of your app...</description></item></channel></rss>