<?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: Code Blocks vs. Code Behind</title><link>http://forums.asp.net/thread/2275810.aspx</link><pubDate>Fri, 04 Apr 2008 03:21:12 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2275810</guid><dc:creator>pure.krome</dc:creator><author>pure.krome</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2275810.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2275810</wfw:commentRss><description>&lt;p&gt;great post and discussion, people :)&lt;/p&gt;</description></item><item><title>Re: Code Blocks vs. Code Behind</title><link>http://forums.asp.net/thread/2274801.aspx</link><pubDate>Thu, 03 Apr 2008 16:43:39 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2274801</guid><dc:creator>sodablue</dc:creator><author>sodablue</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2274801.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2274801</wfw:commentRss><description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Don&amp;#39;t allow&amp;nbsp;a history of bad apps in code blocks steer you just because you see the reminding &amp;lt;%&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;h1 style="FONT-SIZE:12px;MARGIN:0px;"&gt;&lt;em&gt;“The cat, having sat upon a hot stove lid, will not sit upon a hot stove lid again. But he won&amp;#39;t sit upon a cold stove lid, either.” - Mark Twain&lt;/em&gt;&lt;/h1&gt;
&lt;p style="FONT-SIZE:12px;MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;
&lt;p style="FONT-SIZE:12px;MARGIN:0px;"&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Code Blocks vs. Code Behind</title><link>http://forums.asp.net/thread/2274278.aspx</link><pubDate>Thu, 03 Apr 2008 13:23:36 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2274278</guid><dc:creator>paul.vencill</dc:creator><author>paul.vencill</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2274278.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2274278</wfw:commentRss><description>&lt;p&gt;Agreed.&amp;nbsp; I&amp;#39;ve become very comfortable very quickly with the combination of regular XHTML, code blocks (in small doses) and HtmlHelpers. I have long been gravitating toward having more and more output control than the more popular webforms-based controls give you anyway.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;That said, as Scott Hanselman says, it&amp;#39;s really all about choice.&amp;nbsp; Anyone who prefers controls... frankly, it&amp;#39;s *trivial* to throw together a wrapper around HtmlHelpers if all you&amp;#39;re trying to do is get away from the &amp;lt;% %&amp;gt; syntax.&amp;nbsp; If complex controls are your bag, then it&amp;#39;s somewhat easier (imo) to build mvc-compliant controls than it is to build webforms-based controls, since it&amp;#39;s closer to a &amp;#39;pure&amp;#39; class (in that it doesn&amp;#39;t have things like viewstate or controlstate to manage).&amp;nbsp; You&amp;#39;re basically just building a simple string parsing engine at that point...&amp;nbsp; Finally, if you&amp;#39;re not interested in building your own controls, I&amp;#39;m sure it&amp;#39;s not too long after this thing gets released (remember, we *are* talking about beta software...) that you see guys like Telerik and RadControls coming up with MVC-compliant complex controls.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Paul&lt;/p&gt;</description></item><item><title>Re: Code Blocks vs. Code Behind</title><link>http://forums.asp.net/thread/2273680.aspx</link><pubDate>Thu, 03 Apr 2008 08:39:25 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2273680</guid><dc:creator>TheDeathArt</dc:creator><author>TheDeathArt</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2273680.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2273680</wfw:commentRss><description>&lt;p&gt;Preferable not. The best thing Microsoft can do is to do as little work on view-engines as possible, and focus on the framework instead.&lt;br /&gt;&lt;br /&gt;Personaly I prefer the current viewengine, but if I wanted a XML look&amp;#39;alike engine, I would use XSL(T) , definitive. The problem is, no view engines besides&lt;br /&gt;the current ASP.NET viewengine offers enough flexibility for the amount of different browsers and operativ-systemers.&lt;/p&gt;&lt;p&gt;And then we can start talking about browser specific features, DOM scripting etc. From my point of view, the majority who were extremly happy with webforms,&lt;br /&gt;where the people who made websites for Internet Explorer only. But since this violates laws in now several European countries , it&amp;#39;s not a valid argument anymore for ANYONE.&lt;/p&gt;&lt;p&gt;And in reality, you are likely to end up writing LESS code using the default view engine, compared to WebForms. Lambda expressions and ViewHelpers are a godly combination.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Code Blocks vs. Code Behind</title><link>http://forums.asp.net/thread/2271906.aspx</link><pubDate>Wed, 02 Apr 2008 14:38:15 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2271906</guid><dc:creator>superevanc</dc:creator><author>superevanc</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2271906.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2271906</wfw:commentRss><description>&lt;p&gt;I believe part of the problem is that some people find there is a smell with the &lt;font face="arial" size="2"&gt;ASP.NET view engine.&amp;nbsp; There are other view engines that are out there.&amp;nbsp; I haven&amp;#39;t had a chance to try any out with ASP.NET MVC yet.&amp;nbsp; The nhaml project looks really cool and that is probably at the top of my list to try: &lt;/font&gt;&lt;a href="http://andrewpeters.net/2007/12/19/introducing-nhaml-an-aspnet-mvc-view-engine/" title="nhaml"&gt;http://andrewpeters.net/2007/12/19/introducing-nhaml-an-aspnet-mvc-view-engine/&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;I hear that nvelocity also works with asp.net mvc but I haven&amp;#39;t seen this in action either.&amp;nbsp; I&amp;#39;ve used nvelocity with monorail and although I think the master page concept works better in the ASP.NET view engine nvelocity has a lot more readability.&lt;/p&gt;&lt;p&gt;I would like to see Microsoft put some effort into a new view engine.&amp;nbsp; Trying to make use of the existing ASP.NET one is all well and good to get things going and help converts, but I find it very hard to use and maintain for MVC style apps.&lt;br /&gt;&amp;nbsp;&lt;/p&gt;&lt;a href="http://andrewpeters.net/2007/12/19/introducing-nhaml-an-aspnet-mvc-view-engine/" title="nhaml"&gt;&lt;br /&gt;&lt;/a&gt;</description></item><item><title>Re: Code Blocks vs. Code Behind</title><link>http://forums.asp.net/thread/2264014.aspx</link><pubDate>Sat, 29 Mar 2008 19:19:53 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2264014</guid><dc:creator>srulyt</dc:creator><author>srulyt</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2264014.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2264014</wfw:commentRss><description>&lt;p&gt;I think it would be nice if the MVC team put out a few more helper methods and a few controls that would help the developers who do not want to put logic in their vies avoid it. As for those who don&amp;#39;t mind and prefer more control over the output using inline code is fine. It is not like classic asp, as many have said, becuase it is only view logic. It is also different than asp because in the end it uses the Asp.Net pipeline and gets precompiled making it run faster and less buggy.&lt;/p&gt;
&lt;p&gt;I played around with the webforms view engine and i was able to add server side controls and it ran very nicely. I used a server side form and agrid view in my test and it rendered like any webforms page would. I added a button to see what the postback would od and it caused a regular MVC pattern. It seems that should one really like webforms but still want to use MVC they could be used together. This does seem to have some serious performance issues because now yoy have to run the MVC pattern and the regular pagecycle and render a control tree, but if this is not an issue in your case using server controls seemed to work fine in MVC&lt;/p&gt;</description></item><item><title>Re: Code Blocks vs. Code Behind</title><link>http://forums.asp.net/thread/2263998.aspx</link><pubDate>Sat, 29 Mar 2008 18:59:46 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2263998</guid><dc:creator>tgmdbm</dc:creator><author>tgmdbm</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2263998.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2263998</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;DavidKiff:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;however should the logic be extracted away from the mark-up?&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;This is a choice for you as a developer. As Micheal suggests it&amp;#39;s all about readability.&lt;/p&gt;&lt;p&gt;First of all, do not be afraid of code blocks, they are your friend! But if you think your code blocks aren&amp;#39;t very readable, try putting it in a helper method. If your helper methods don&amp;#39;t do it for you, create a control for it.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;You have so much choice. Experiment.&lt;/p&gt;</description></item><item><title>Re: Code Blocks vs. Code Behind</title><link>http://forums.asp.net/thread/2263779.aspx</link><pubDate>Sat, 29 Mar 2008 14:36:18 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2263779</guid><dc:creator>tcox</dc:creator><author>tcox</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2263779.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2263779</wfw:commentRss><description>&lt;p&gt;I work in an agile shop. We examine the value for each piece--even separation of concerns.&lt;/p&gt;
&lt;p&gt;Don&amp;#39;t do things academically. Do them because they matter and bring value.&lt;/p&gt;
&lt;p&gt;For a quick UI, to get feedback from the user, we&amp;#39;ll put it ALL on the page using prototype.js.&lt;br /&gt;If the logic is ONLY about UI, that&amp;#39;s where it belongs. That&amp;#39;s where you develop it and test it, so maitain it there.&lt;/p&gt;
&lt;p&gt;If&amp;nbsp;the app&amp;nbsp;uses the database&amp;nbsp;to the point the controller would start to look like a repository, guess what,&amp;nbsp;we need a repository.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;value should be what drives development. Patterns are just another tool in your belt.&lt;/p&gt;
&lt;p&gt;If it&amp;#39;s easy to maintain and refactor, it&amp;#39;s the right pattern for this app--maybe not the next one.&lt;/p&gt;
&lt;p&gt;Don&amp;#39;t allow&amp;nbsp;a history of bad apps in code blocks steer you just because you see the reminding &amp;lt;%&lt;/p&gt;</description></item><item><title>Re: Code Blocks vs. Code Behind</title><link>http://forums.asp.net/thread/2263600.aspx</link><pubDate>Sat, 29 Mar 2008 11:20:04 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2263600</guid><dc:creator>DavidKiff</dc:creator><author>DavidKiff</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2263600.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2263600</wfw:commentRss><description>&lt;p&gt;Hey,&lt;/p&gt;
&lt;p&gt;Good answers&lt;font color="#000000"&gt; Michael Carman&amp;nbsp;&lt;/font&gt;and tgmdbm.&amp;nbsp; tgmdbm I think you&amp;#39;ve changed my my opinion of inline code blocks.&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;tgmdbm:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;The point is, this logic is &amp;quot;view logic&amp;quot; which absolutely belongs inside the view &lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;
&lt;p&gt;Absolutly right, however should the logic be extracted away from the mark-up?&amp;nbsp; In WebForms there is still view logic but its not mixed in the HTML its nicely placed inthe codebehind.. or abstracted away into the server controls themselves. &lt;/p&gt;
&lt;p&gt;Saying this you have made some really interesting advantages that seem to out weight the non-seperation of GUI logic and markup.. The perfomance gain one is rather obvious.. now you have mentioned it!&amp;nbsp; and then the light &amp;quot;weightness&amp;quot; of everything seems cool.. why have a resource eating gridview when you dont use half the features..hmm&lt;/p&gt;
&lt;p&gt;Thanks alot for the input this is what I was after in the first place! &lt;img src="http://forums.asp.net/emoticons/emotion-2.gif" alt="Big Smile" /&gt;&lt;/p&gt;
&lt;p&gt;David&lt;/p&gt;</description></item><item><title>Re: Code Blocks vs. Code Behind</title><link>http://forums.asp.net/thread/2263373.aspx</link><pubDate>Sat, 29 Mar 2008 05:44:06 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2263373</guid><dc:creator>Michael Carman</dc:creator><author>Michael Carman</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2263373.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2263373</wfw:commentRss><description>&lt;p&gt;Yea, this is a good discussion.&amp;nbsp; I personally use a combination of inline code, HTML helpers and server controls.&amp;nbsp;&amp;nbsp; For reason already mentioned in this thread (refactoring,&amp;nbsp;type safey,&amp;nbsp;etc..),&amp;nbsp;I always use inline code when referencing the model.&amp;nbsp; But I do like to use server controls for common HTML blocks. For example,&amp;nbsp;here is a&amp;nbsp;some of code for a simple form.&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;&lt;span class="dir"&gt;&amp;lt;%=&lt;/span&gt;Url.Action(new {action=&amp;quot;SaveContact&amp;quot;, id=ViewData.ContactId})&lt;span class="dir"&gt;%&amp;gt;&lt;/span&gt;&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;&lt;span class="attr"&gt; id=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;ContactForm&amp;quot;&lt;/span&gt;&amp;gt;
               
        &amp;lt;&lt;span class="tag"&gt;ui:FieldContainer&lt;/span&gt;&lt;span class="attr"&gt; ID=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;FirstNameCt&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; Label=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;First Name&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; Required=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; runat=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;server&amp;quot;&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;text&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; name=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;FirstName&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; value=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;&lt;span class="dir"&gt;&amp;lt;%=&lt;/span&gt; ViewData.FirstName &lt;span class="dir"&gt;%&amp;gt;&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; maxlength=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;50&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; size=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;50&amp;quot;&lt;/span&gt; /&amp;gt;
        &amp;lt;/&lt;span class="tag"&gt;ui:FieldContainer&lt;/span&gt;&amp;gt;
        
        &amp;lt;&lt;span class="tag"&gt;ui:FieldContainer&lt;/span&gt;&lt;span class="attr"&gt; ID=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;LastNameCt&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; Label=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;Last Name&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; Required=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; runat=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;server&amp;quot;&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;text&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; name=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;LastName&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; value=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;&lt;span class="dir"&gt;&amp;lt;%=&lt;/span&gt; ViewData.LastName &lt;span class="dir"&gt;%&amp;gt;&lt;/span&gt;&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; maxlength=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;50&amp;quot;&lt;/span&gt;&lt;span class="attr"&gt; size=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;50&amp;quot;&lt;/span&gt; /&amp;gt;
        &amp;lt;/&lt;span class="tag"&gt;ui:FieldContainer&lt;/span&gt;&amp;gt;           
                    
        &amp;lt;&lt;span class="tag"&gt;div&lt;/span&gt;&lt;span class="attr"&gt; class=&lt;/span&gt;&lt;span class="attrv"&gt;&amp;quot;buttonContainer&amp;quot;&lt;/span&gt;&amp;gt;
            &amp;lt;&lt;span class="tag"&gt;button&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;&amp;gt;&amp;lt;&lt;span class="tag"&gt;span&lt;/span&gt;&amp;gt;Save&amp;lt;/&lt;span class="tag"&gt;span&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span class="tag"&gt;button&lt;/span&gt;&amp;gt;
        &amp;lt;/&lt;span class="tag"&gt;div&lt;/span&gt;&amp;gt;                   
&amp;lt;/&lt;span class="tag"&gt;form&lt;/span&gt;&amp;gt;
&lt;/pre&gt;
&lt;p&gt;I am using the FieldContainer control to&amp;nbsp;wrap the fields with the appropriate div&amp;#39;s and labels.&amp;nbsp; I probably could have created a helper method like Html.FieldContainer(&amp;quot;FirstNameCt&amp;quot;, &amp;quot;First Name&amp;quot;, true). But I found the server control easier to read.&amp;nbsp;&amp;nbsp;In the end, my goal is to create code that easy to read (discoverable) and maitain.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To answer the original posters question, I don&amp;#39;t see anything wrong with using code blocks for the diplay logic. Code blocks gives us type safety, the abililty to refactor, and better performance.&amp;nbsp; Can it be misused? Sure, but so can server controls.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;On a side note, since we do not have to deal with ViewState and post backs in MVC, creating server controls is much easier :)&lt;/p&gt;</description></item><item><title>Re: Code Blocks vs. Code Behind</title><link>http://forums.asp.net/thread/2263220.aspx</link><pubDate>Sat, 29 Mar 2008 01:06:07 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2263220</guid><dc:creator>tgmdbm</dc:creator><author>tgmdbm</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2263220.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2263220</wfw:commentRss><description>&lt;p&gt;Great discussion guys.&lt;/p&gt;&lt;p&gt;I have a 4 comments. please read through before flaming *wink and a smile*&lt;br /&gt;&lt;/p&gt;&lt;p&gt;1) People tend to complain about &amp;quot;logic in the view&amp;quot; and talk about &amp;quot;logic vs markup&amp;quot;. They say that &amp;quot;logic doesn&amp;#39;t belong in the view&amp;quot;, but whether you&amp;#39;re using controls or code blocks, you&amp;#39;re still using logic. The point is, this logic is &amp;quot;view logic&amp;quot; which absolutely belongs inside the view (whether it&amp;#39;s hidden inside controls or visible in code blocks)&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;DavidKiff:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;[GridView exmaple]&lt;br /&gt;&lt;br /&gt;Less lines of code!! No foreach logic within the markup!&amp;nbsp; The only
advantage I can see that the MVC view has is type-safty!&amp;nbsp; If you really
want complete control over you code why not use a repeater?&amp;nbsp; That is
the reason they are designed!!&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;You forgot the lines of code which bind the GridView to a data source. Whether you&amp;#39;re defining your data source declaratively, or in code behind, (apart from more lines of code) you&amp;#39;re separating it from the grid which makes it a little less discoverable. You&amp;#39;re right in saying that the foreach isn&amp;#39;t in the markup, but the &amp;quot;logic&amp;quot; is still there, you&amp;#39;ve just hidden it inside your GridView. This just means you need to understand what your controls are doing behind the scenes, where as &amp;quot;foreach&amp;quot; and &amp;quot;if&amp;quot; can almost be read in english.&lt;/p&gt;&lt;p&gt;2) You mentioned type-safety. Absolutely! But more than that.&lt;/p&gt;&lt;p&gt;a) With data binding you&amp;#39;re performing reflection on the data source, so our &amp;quot;type safety&amp;quot; has a significant performance gain.&lt;br /&gt;b) The code is visible to refactoring tools (like Resharper, but not VS?! lol) so when you refactor your data types, Resharper can update the references in your view, but it won&amp;#39;t touch things like Eval(&amp;quot;el.Value&amp;quot;).&lt;br /&gt;c) Intellisense&lt;/p&gt;&lt;p&gt;3) Don&amp;#39;t get me wrong, I&amp;#39;m not saying you should use code blocks everywhere. If you do, you&amp;#39;re bound create a maintenance nightmare (I&amp;#39;ve been there). We need a little help. And for this, we have helper methods. HtmlHelper is full of neat little nuggets of html which we can just drop into our pages. We can even avoid using reflection on our data sources by passing delegates to our helper methods (I&amp;#39;m pretty sure this will be implemented in a future release of the framework but you can write it yourself for now). You can&amp;#39;t exactly pass delegates to a control!&lt;br /&gt; &lt;/p&gt;&lt;p&gt;You&amp;#39;re still using &amp;lt;%%&amp;gt; tho, but Html.TextBox() feels more like a control.&amp;nbsp;&lt;/p&gt;&lt;p&gt;4) You asked &amp;quot;why not use a repeater?&amp;quot;, you can. And, assuming the MVC team haven&amp;#39;t changed their minds, you&amp;#39;ll be able to use &amp;lt;mvc: controls just like the &amp;lt;asp: ones you&amp;#39;re used to. They&amp;#39;ll output nice html but obviously won&amp;#39;t respond to postback events etc. They will apparently be wrappers around the HtmlHelper methods (from what I heard).&lt;/p&gt;&lt;p&gt;Plus you can still use your own controls and put some logic in the code behind, as long as you&amp;#39;re careful not to expect the WebForms postback model. But a lot of people here frown on using code behind, especially since we don&amp;#39;t have to any more.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;But as Scott Hanselman said &amp;quot;We&amp;#39;ve already got a Repeater, it&amp;#39;s called &amp;quot;foreach&amp;quot;.&amp;quot;&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Code Blocks vs. Code Behind</title><link>http://forums.asp.net/thread/2262921.aspx</link><pubDate>Fri, 28 Mar 2008 20:21:44 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2262921</guid><dc:creator>jbardrof</dc:creator><author>jbardrof</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2262921.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2262921</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;DavidKiff:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;Ok change of mind!! I think the MVC Framework is great for people who
dont understand how to use WebForms and strugle to understand the page
cycle eyc!&amp;nbsp; The MVC model is much simpler to use. &lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;That perfectly highlights your basic opinion.&amp;nbsp; I for one love the new MVC way of handling things and I had absolutely no trouble understanding the page lifecycle. I never liked it, never liked viewstate, pages got bloated. In fact I would have to say that Webforms are great for people that don&amp;#39;t understand how to manipulate the stateless nature of the web. Webforms injects a pseudo state into a stateless entity.&amp;nbsp; The idea of RESTful web apps and other such notions that many other frameworks employ was not followed by asp.net. Of course, its fine that MS went in a different direction, but for those of us who would rather have full control of their html, MVC is a better option.&amp;nbsp; Webforms creates a sense of security against having to understand html, while some may like that approach, it is no way a superior approach which would make MVC the lesser paradigm.&amp;nbsp; &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Code Blocks vs. Code Behind</title><link>http://forums.asp.net/thread/2262919.aspx</link><pubDate>Fri, 28 Mar 2008 20:21:30 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2262919</guid><dc:creator>DavidKiff</dc:creator><author>DavidKiff</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2262919.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2262919</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;ShaneBauer:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;Honestly, I stopped reading your post after the first sentence&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;
&lt;p&gt;You read the end &lt;img src="http://forums.asp.net/emoticons/emotion-1.gif" alt="Smile" /&gt;&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;ShaneBauer:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;so why shouldn&amp;#39;t the application framework be simple as well&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;
&lt;p&gt;Why should it not!?&amp;nbsp; To behonest as ive already said I like the MVC Framework, even written some sites in it already &lt;img src="http://forums.asp.net/emoticons/emotion-2.gif" alt="Big Smile" /&gt;!&amp;nbsp; The debate im raising (educational) &lt;strong&gt;is it good that markup and code is mixed together?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I have come from a classic asp background into .NET and yes in the begining I struggled to understand why its better especially with the lack of control over the markup...however after three years of experiance with asp.net webforms I now understand why its better and understand you have as much control you want over the markup!&amp;nbsp; If I was starting out now, I would probably perfer the MVC Framework because back then I wouldnt have understood why webforms has been made like it has.&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;ShaneBauer:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;If you don&amp;#39;t see the benefits, then don&amp;#39;t use it&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;
&lt;p&gt;I do...ive used it!! You&amp;#39;re missing my point!&amp;nbsp; &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;ShaneBauer:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;to tell someone why they should use a tool isn&amp;#39;t beneficial for anyone&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;
&lt;p&gt;Im not telling!&amp;nbsp; Im not saying dont use MVC and use webforms instead.. Im saying is it a good idea to mix markup with code? I dont mind what other people do!&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;ShaneBauer:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;saying that a certain tool is only for people that can&amp;#39;t understand another is ridiculous.&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;
&lt;p&gt;You have taken this out of context or I did not make my implication understandable.&amp;nbsp; I was trying to say its easier for people begining asp.net development.. there is far less to learn in terms of various server side controls etc.&amp;nbsp; This isnt to say its no an appropriate framework for experianced people either!!&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;</description></item><item><title>Re: Code Blocks vs. Code Behind</title><link>http://forums.asp.net/thread/2262811.aspx</link><pubDate>Fri, 28 Mar 2008 19:16:55 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2262811</guid><dc:creator>ShaneBauer</dc:creator><author>ShaneBauer</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2262811.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2262811</wfw:commentRss><description>&lt;p&gt;Honestly, I stopped reading your post after the first sentence. The last part is correct, though. &amp;quot;The MVC model is much simpler to use.&amp;quot; That&amp;#39;s right. HTTP is simple, so why shouldn&amp;#39;t the application framework be simple as well. There is no such thing as a page life cycle in HTTP. You have a responses and requests. Why should WebForms have numerous events for a single page? &lt;/p&gt;&lt;p&gt;&amp;nbsp;WebForms is Windows forms for the Web (hence the name). WebForms wasn&amp;#39;t created for smart people to show off their understanding of events.&lt;/p&gt;&lt;p&gt;&amp;nbsp;Again, MVC isn&amp;#39;t for everyone. If you don&amp;#39;t see the benefits, then don&amp;#39;t use it. Not everyone will like it. Spending two pages on a forum trying to tell someone why they should use a tool isn&amp;#39;t beneficial for anyone. Coming here to spark debate and learn is one thing, but saying that a certain tool is only for people that can&amp;#39;t understand another is ridiculous.&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Code Blocks vs. Code Behind</title><link>http://forums.asp.net/thread/2262783.aspx</link><pubDate>Fri, 28 Mar 2008 19:01:08 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2262783</guid><dc:creator>DanFinch</dc:creator><author>DanFinch</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2262783.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1146&amp;PostID=2262783</wfw:commentRss><description>&lt;p&gt;When I first took a look at ASP.NET MVC I was wary of the inclusion of .aspx but after working with it for a while I&amp;#39;m beginning to favor spaghetti code in MVC. In web forms it quickly got hairy and there&amp;#39;s every opportunity to avoid unreadable nonsense entirely in MVC (helpers), but it&amp;#39;s a great templating solution for people who want to work intimately with the standards, but I&amp;#39;ve found use for view-specific helper methods in code-behind which use System.Web.UI.HtmlControls. It depends on the view.&lt;br /&gt;&lt;/p&gt;</description></item></channel></rss>