<?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: Basic questions concerning the MVC framework overall</title><link>http://forums.asp.net/thread/3274838.aspx</link><pubDate>Sat, 04 Jul 2009 16:53:41 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3274838</guid><dc:creator>liaothomas</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3274838.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=3274838</wfw:commentRss><description>&lt;p&gt;With respect to a common form between new and edit, the best solution that I have seen is the use of a partial view.&amp;nbsp; You can take all of the comon elements (logic and controls)&amp;nbsp;and place them into a partial view.&amp;nbsp; For the partial to appear on a page you use the Html helper method, RenderPartial(&amp;quot;PartialViewName&amp;quot;).&amp;nbsp; The partial view is contained in an ASCX file.&amp;nbsp; The PartialViewName works the same way as view names (MyView.asmx for the same controller is View(&amp;quot;MyView&amp;quot;).&amp;nbsp; If the partial view is located in the same controler as MyView, my view contains &amp;lt;%= Html.RenderPartial(&amp;quot;PartialViewName&amp;quot;) %&amp;gt; (Assuming that the partial view file is named PartialViewName.ascx.&lt;/p&gt;
&lt;p&gt;You might want to work through one of the available tutorials for MVC 1.0 that are available on the wen.&lt;/p&gt;</description></item><item><title>Re: Basic questions concerning the MVC framework overall</title><link>http://forums.asp.net/thread/2280216.aspx</link><pubDate>Mon, 07 Apr 2008 06:17:48 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2280216</guid><dc:creator>armaSANEA</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2280216.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2280216</wfw:commentRss><description>&lt;p&gt;Placing a name attribute on the html file input did the trick. I&amp;#39;m going to stay away from runat=&amp;quot;server&amp;quot; for now :)&lt;br /&gt; &lt;/p&gt;&lt;p&gt;Thanks a bunch! &lt;/p&gt;</description></item><item><title>Re: Basic questions concerning the MVC framework overall</title><link>http://forums.asp.net/thread/2279500.aspx</link><pubDate>Sun, 06 Apr 2008 14:34:56 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2279500</guid><dc:creator>jgo23</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2279500.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2279500</wfw:commentRss><description>&lt;p&gt;I also had to attribue the containing form with &amp;quot;runat=server&amp;quot;, as well.&amp;nbsp; The view/controller still works and remains unaffected by doing this, however, after reading the link posted after yours, i think the reason why the non-asp.net input wasn&amp;#39;t working for me was probably because I was missing the name attribute.&amp;nbsp; I just tried this method and it does work, so probably just a good idea to stay away from the FileUpload server control (although, it seems to work just fine).&lt;/p&gt;</description></item><item><title>Re: Basic questions concerning the MVC framework overall</title><link>http://forums.asp.net/thread/2279480.aspx</link><pubDate>Sun, 06 Apr 2008 14:12:11 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2279480</guid><dc:creator>tumickey</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2279480.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2279480</wfw:commentRss><description>upload with mvc :) http://forums.asp.net/t/1237419.aspx&lt;br /&gt;</description></item><item><title>Re: Basic questions concerning the MVC framework overall</title><link>http://forums.asp.net/thread/2279291.aspx</link><pubDate>Sun, 06 Apr 2008 10:14:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2279291</guid><dc:creator>armaSANEA</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2279291.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2279291</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Hi, you stated that&lt;/p&gt;&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;jgo23:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt; With no code changes except for this replacement, I could then see the uploaded file from my controller.&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;But I get an Parser error if I place an &amp;lt;asp:FileUpload runat=&amp;quot;server&amp;quot;/&amp;gt; inside a form without runat=&amp;quot;server&amp;quot;:&lt;/p&gt;&lt;p&gt;&amp;nbsp;Control &lt;span class="st"&gt;&amp;#39;ctl00_MainContentPlaceHolder_DllFile&amp;#39;&lt;/span&gt; of type &lt;span class="st"&gt;&amp;#39;FileUpload&amp;#39;&lt;/span&gt; must be placed inside a form tag with runat=server.&lt;/p&gt;&lt;p&gt;Can you post a complete source page for your file upload? Thanks!&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Basic questions concerning the MVC framework overall</title><link>http://forums.asp.net/thread/2185526.aspx</link><pubDate>Wed, 20 Feb 2008 20:28:03 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2185526</guid><dc:creator>jgo23</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2185526.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2185526</wfw:commentRss><description>&lt;p&gt;Hi Mike (or maybe anyone else)...&lt;/p&gt;
&lt;p&gt;but have you tried out the snippet you provided (below)? 
&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;Mike343:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt; 
&lt;p&gt;&amp;nbsp;This is actually really simple.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;HTML (View)&lt;/strong&gt;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&amp;lt;&lt;span class="tag"&gt;form&lt;/span&gt;&lt;span class="attr"&gt; action=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; enctype=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;multipart/form-data&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; method=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;post&amp;quot;&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span class="tag"&gt;input&lt;/span&gt;&lt;span class="attr"&gt; name=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;upload&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; type=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;file&amp;quot;&lt;/span&gt; /&amp;gt;
&amp;lt;&lt;span class="tag"&gt;br&lt;/span&gt; /&amp;gt;
&amp;lt;&lt;span class="tag"&gt;input&lt;/span&gt;&lt;span class="attr"&gt; type=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;submit&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; value=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;Upload&amp;quot;&lt;/span&gt; /&amp;gt;
&amp;lt;/&lt;span class="tag"&gt;form&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;C# (Action)&lt;/strong&gt;&lt;/p&gt;&lt;pre class="coloredcode"&gt;HttpPostedFile upload = HttpContext.Current.Request.Files[&lt;span class="st"&gt;&amp;quot;upload&amp;quot;&lt;/span&gt;];&lt;/pre&gt;
&lt;p&gt;&amp;nbsp;&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;When I tried it, The Files collection was always empty,but I could see the input coming across with the path.&amp;nbsp; I did get it to work finally by&amp;nbsp;instead using the plain vanilla &amp;quot;&amp;lt;input type=&amp;quot;file&amp;quot;.... &amp;quot; element, I replaced it with the asp.net FileUpload user control, ie &amp;lt;asp:FileUpload ID=&amp;quot;Avatar&amp;quot; runat=&amp;quot;server&amp;quot; /&amp;gt;.&amp;nbsp; With no code changes except for this replacement, I could then see the uploaded file from my controller.&lt;/p&gt;
&lt;p&gt;Can someone explain this?&amp;nbsp; From reading up on articles [1], I think it has something to do with actually needing to &lt;em&gt;process &lt;/em&gt;it, and I think in this case, asp.net is processing it because of the server side control.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;[1] &lt;a href="http://www.cs.tut.fi/~jkorpela/forms/file.html"&gt;http://www.cs.tut.fi/~jkorpela/forms/file.html&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Re: Basic questions concerning the MVC framework overall</title><link>http://forums.asp.net/thread/2149796.aspx</link><pubDate>Sat, 02 Feb 2008 21:06:03 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2149796</guid><dc:creator>rjcox</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2149796.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2149796</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;tgmdbm:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;they would if they didn&amp;#39;t explicitly require i&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I.e. depend on it.&lt;/p&gt;&lt;p&gt;Which is why I said that.&lt;/p&gt;&lt;p&gt;(And was including third party control suites in the &amp;quot;many if not most&amp;quot;).&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Basic questions concerning the MVC framework overall</title><link>http://forums.asp.net/thread/2149312.aspx</link><pubDate>Sat, 02 Feb 2008 11:21:22 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2149312</guid><dc:creator>Mike343</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2149312.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2149312</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;This is actually really simple.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;HTML (View)&lt;/strong&gt;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&amp;lt;&lt;span class="tag"&gt;form&lt;/span&gt;&lt;span class="attr"&gt; action=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; enctype=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;multipart/form-data&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; method=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;post&amp;quot;&lt;/span&gt;&amp;gt;
&amp;lt;&lt;span class="tag"&gt;input&lt;/span&gt;&lt;span class="attr"&gt; name=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;upload&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; type=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;file&amp;quot;&lt;/span&gt; /&amp;gt;
&amp;lt;&lt;span class="tag"&gt;br&lt;/span&gt; /&amp;gt;
&amp;lt;&lt;span class="tag"&gt;input&lt;/span&gt;&lt;span class="attr"&gt; type=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;submit&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; value=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;Upload&amp;quot;&lt;/span&gt; /&amp;gt;
&amp;lt;/&lt;span class="tag"&gt;form&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;C# (Action)&lt;/strong&gt;&lt;/p&gt;&lt;pre class="coloredcode"&gt;HttpPostedFile upload = HttpContext.Current.Request.Files[&lt;span class="st"&gt;&amp;quot;upload&amp;quot;&lt;/span&gt;];&lt;/pre&gt;&amp;nbsp;</description></item><item><title>Re: Basic questions concerning the MVC framework overall</title><link>http://forums.asp.net/thread/2149299.aspx</link><pubDate>Sat, 02 Feb 2008 10:58:17 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2149299</guid><dc:creator>Jeinhor</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2149299.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2149299</wfw:commentRss><description>&lt;p&gt;Thanks for you answers!&lt;/p&gt;
&lt;p&gt;The remaining question is about file upload, but I guess that could be handled with a comon HTML upload file control?&lt;/p&gt;</description></item><item><title>Re: Basic questions concerning the MVC framework overall</title><link>http://forums.asp.net/thread/2148449.aspx</link><pubDate>Fri, 01 Feb 2008 19:28:07 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2148449</guid><dc:creator>tgmdbm</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2148449.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2148449</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;cox, it seems you don&amp;#39;t fully understand ViewState, i know this point is mute because we never have to worry about it anymore, but...&lt;/p&gt;&lt;p&gt;In asp.net, when a page is built during a postback, each control gets its own viewstate which gets populated with the defaults of the control (defined by attributes), then they get overwritten by the declarative properties (as defined in&amp;nbsp; the aspx page). THEN the viewstate gets deserialised from the postback and the properties get overwritten again. then trackchanges is called and the rest of the lifecycle happens yadda yadda then the viewstate gets serialised back and output into the hidden field on the page.&lt;/p&gt;&lt;p&gt;So even if you remove the viewstate postback, you still get a control where all the properties are either default, or as declared on the aspx page, or overwritten in code behind.&lt;/p&gt;&lt;p&gt;They still work without viewstate, or at least, they would if they didn&amp;#39;t explicitly require it (because viewstate is needed to respond to certain events.)&lt;/p&gt;&lt;br /&gt;&lt;p&gt;Now you know, and knowing is half the battle.&lt;/p&gt;&lt;p&gt;because KNOWLEDGE is POWER&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Basic questions concerning the MVC framework overall</title><link>http://forums.asp.net/thread/2147631.aspx</link><pubDate>Fri, 01 Feb 2008 13:01:41 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2147631</guid><dc:creator>Fredrik N</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2147631.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2147631</wfw:commentRss><description>&lt;p&gt;rjcox have answerd most of the questions you have, but I will add something:&lt;/p&gt;
&lt;p&gt;&amp;gt;I don&amp;#39;t fully understand why I can&amp;#39;t use ordinary TextBoxes instead of the helper methods in MVC toolkit?&lt;/p&gt;
&lt;p&gt;When you use the TextBox control, you need to place it inside of a &amp;lt;form runat=&amp;quot;server&amp;quot;&amp;gt;, you also need to dynamically set the Text property in the code-behind to give it a value. You can use HTML Web Server Controls to avoid using the &amp;lt;form runat=&amp;quot;server&amp;quot;&amp;gt;. But I don&amp;#39;t like the solution where there will be&amp;nbsp;two files where we put logic&amp;nbsp;which influence the rendering of the View, the .aspx page and the code-behind.&lt;/p&gt;</description></item><item><title>Re: Basic questions concerning the MVC framework overall</title><link>http://forums.asp.net/thread/2147520.aspx</link><pubDate>Fri, 01 Feb 2008 11:54:53 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2147520</guid><dc:creator>rjcox</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2147520.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2147520</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Partial answers:&lt;/p&gt;&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;Jeinhor:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;I don&amp;#39;t fully understand why I can&amp;#39;t use ordinary TextBoxes instead of the helper methods in MVC toolkit?&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;You can. There is no requirement to use the helpers.&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;Jeinhor:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;This is related to the above question, but what about viewstate controls? &lt;/div&gt;&lt;/BLOCKQUOTE&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;No ViewState with MVC, so anything that depends on ViewState (and this includes many, if not most, server controls) is not usable with MVC.&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;Jeinhor:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt; often combine my New and Edit forms, but Scott seems to create different views for this. Is there any problem with MVC and combining those forms?&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;You can (and I have), you&amp;#39;ll likely want to look at how you label/title things and your new/create/edit/update actions will need to be consistent.&lt;/p&gt;&lt;p&gt;Combining works well when you need the ability to send a &amp;quot;new&amp;quot; form back to the user due to invalid/incomplete input beforte creating the new entity.&amp;nbsp;&lt;/p&gt;</description></item><item><title>Basic questions concerning the MVC framework overall</title><link>http://forums.asp.net/thread/2147450.aspx</link><pubDate>Fri, 01 Feb 2008 11:09:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2147450</guid><dc:creator>Jeinhor</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2147450.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2147450</wfw:commentRss><description>&lt;p&gt;Hello,&lt;/p&gt;&lt;p&gt;&amp;nbsp;I&amp;#39;ve read the excellent blog series by ScottGu concerning the MVC framework and I now have the following questions:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;How will I handle file uploads?&lt;/li&gt;&lt;li&gt;I don&amp;#39;t fully understand why I can&amp;#39;t use ordinary TextBoxes instead of the helper methods in MVC toolkit?&lt;/li&gt;&lt;li&gt;This is related to the above question, but what about viewstate controls? If I check the users input in a New-view and I find input errors I wish them to correct, will I manually have to preserve the entered values (as postback would&amp;#39;ve done for me)?&lt;/li&gt;&lt;li&gt;I often combine my New and Edit forms, but Scott seems to create different views for this. Is there any problem with MVC and combining those forms?&lt;/li&gt;&lt;/ul&gt;It all seems very neat though!&lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>