01 August 2013

Why I prefer MVC over WebForm in some of my projects

I started creating webpages in 2004 working directly on HTML and CSS in a very plain text editor like Notepad. When I began developing .Net web applications in 2007, I "missed" HTML and CSS a lot. Yeah, I really missed them. The server controls of ASP.NET web forms "handled" it for me while I could focus working on the business logic and data layer of the applications. And to tell you the truth, web form could not handle it correctly for me. SEO is not its best friend!

When I started to learn about MVC and tried some simple web applications in ASP.NET MVC, I began to love what it could bring to me. Aside from a very testable structure, it gave me total "control" over my HTML markups!

Today, I'm missing my web forms and its "magic" HTML and some "hidden" Javascript like this:

<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"  
value="/wEPDwULLTEwMDUwOTU4OTRkGAIFDERldGFpbHNWaWV3MQ9nZAUETVlHVg88KwAMA....
</div>

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>

<div class="aspNetHidden">

 <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION"  
value="/wEdABDcYDKXF9BnQ5mq8JWWwj0BgNp1bfNrgNexLlPS+YFwS9KYjEm1g9YyY3o7......
</div>
 
 
Of course, I will develop another Intranet applications soon and ASP.NET web 
form is a better choice than MVC especially if I'll be "required" to use its 
rich toolbox. 

No comments:

Post a Comment