.NET Development Examined

Everything is Sharper

Thursday, March 10, 2011

Everything is sharper now that Texas Jetter is using MVC3 Razor script! I started development on Texas Jetter late last year, and before I could publish it, Microsoft introduced MVC3 and it's Razor scripting. I decided to go ahead and post what I had, and began the process of converting (and a little refactoring, since you can't do something the same way twice). Things have been a little busy, but finally I was at the point where I could post the Razor version of Texas Jetter.  The conversion was not bad, but I did find a couple of items that gave me,,, um topics to research?

For those of you not familiar with the new Razor syntax, it allows (among other things) a more abbreviated syntax in your markup page. So instead of having

<%: Model.Title %>
you have
It may not seem like such a big deal here, but believe me, it all adds up.

One of the new features that caused me some research was the new unobtrusive javascript feature (check out a great article here by Brad Wilson). While this is a great new feature, I found that it broke my AJAX partial forms. With the unobtrusive javascript enabled all of my AJAX partial forms triggered a full post back. Not cool. After much research the best I could come up with for now is to turn off the unobtrusive script because, well it was being obtrusive....

As Brad notes, you can control this either on a page by page basis with
HtmlHelper.UnobtrusiveJavaScriptEnabled = false;
or in the web.config by
<configuration> <appsettings> <add key="UnobtrusiveJavaScriptEnabled" value="true"></add> </appsettings> </configuration> </div>

I also implemented some custom routing so my posting url's don't look like /Post/Detail/12. They are now a more SEO friendly format like /Article/Razor.
Other little tweaks happened, and will continue to happen as the site continues. 

..Happy Coding and don't cut yourself on the edge.


Add Comment