tag:blogger.com,1999:blog-140551152018-04-28T05:39:21.735-04:00Wayne BrantleyWayne Brantleyhttp://www.blogger.com/profile/10640873225205821040noreply@blogger.comBlogger15125tag:blogger.com,1999:blog-14055115.post-38162486661534685582011-03-08T15:13:00.000-05:002011-03-08T15:13:25.274-05:00MVC3 control Profile with action filterAsp.net profile providers are very useful for storing information about a particular user on your website. When you reference HttpContext.Profile, it is automatically loaded from the database. If you do not reference the profile, it will not be loaded, which works out great.
Changing and saving the profile is another story. You setup your profile provider in the web.config. In that Wayne Brantleyhttp://www.blogger.com/profile/10640873225205821040noreply@blogger.com2tag:blogger.com,1999:blog-14055115.post-89081157522012573272011-03-08T15:12:00.001-05:002011-03-08T15:13:05.969-05:00ASP.NET session state still makes database calls when disabledMVC3 offered us the ability to disable session state in a controller. This allows the elimination when not using session state. So, for example - if you have a controller that manages images for you, previously the session would be loaded on each call. This turns out to be quite expensive. With MVC3, we can now disable that load.
However, even if you use
[SessionState(Wayne Brantleyhttp://www.blogger.com/profile/10640873225205821040noreply@blogger.com1tag:blogger.com,1999:blog-14055115.post-89199786202405614962011-01-17T15:27:00.000-05:002011-01-17T15:27:14.624-05:00MVC3 unobtrusive AJAX and default loading imageWith MVC3's new unobtrusive AJAX and jquery.unobtrusive-ajax.js, all AJAX calls are mapped through jquery. You end up with lots of "data-ajax-xxxxxxx" attributes on your Form tag. Overall this works pretty well.
However, one issue is that _generally_ I want a 'loading' image to show on the start of each ajax call and hide at the end. In order to do that, you must provide the loadingElementIdWayne Brantleyhttp://www.blogger.com/profile/10640873225205821040noreply@blogger.com0tag:blogger.com,1999:blog-14055115.post-64039827487190770962011-01-16T12:11:00.000-05:002011-01-16T12:11:07.142-05:00MVC3 CompareAttribute displays wrong default error messageI am glad to see new compare attribute in MVC3. If you do not specify the optional error message for the compare attribute, it will display everything correctly, except for the name of the field you are comparing to. It does not respect the DisplayName attribute of the compared field. For example, if you have this:
The error message displayed will be:
Notice it does not use the Wayne Brantleyhttp://www.blogger.com/profile/10640873225205821040noreply@blogger.com0tag:blogger.com,1999:blog-14055115.post-89199267710624958752011-01-15T11:54:00.000-05:002011-01-15T11:54:39.922-05:00MVC3 requires unobtrusive validation if you want jquery validationReading all the new things about MVC3, it appeared to me they had all these options to 'not' enable Unobtrusive javascript. Turns out you really have two choices. You can use msajax style validation (regular or unobtrusive) or you can use jquery validation - unobtrusive style.
If you are like me, you have been doing jquery validation all along, using the alternative script Wayne Brantleyhttp://www.blogger.com/profile/10640873225205821040noreply@blogger.com0tag:blogger.com,1999:blog-14055115.post-18365614352291872822011-01-15T11:49:00.001-05:002011-01-15T15:19:13.311-05:00MVC3 breaks any manual use of jquery validateIf MVC client side validation using model attributes just would not do what you needed it to, you could always turn of client side validation and call validate yourself:
$('#myForm').validate({
rules: {
myField: {
minlength: 5, maxlength: 5, required: true, digits: true
}
},
submitHandler: function (form) {
Wayne Brantleyhttp://www.blogger.com/profile/10640873225205821040noreply@blogger.com0tag:blogger.com,1999:blog-14055115.post-82866746185917179812011-01-15T11:47:00.000-05:002011-01-15T11:47:12.497-05:00MVC3 validates hidden fields using jquery validationI am not sure about you, but I rarely, if ever, want to validate a form field that is hidden from view!
Consider the case where you have a several required fields on the screen and the user can take some action that causes some fields to then be hidden. Well, using the default unobtrusive jquery validation, it will still validate those fields. If you do not have a 'SummaryValidation', this Wayne Brantleyhttp://www.blogger.com/profile/10640873225205821040noreply@blogger.com15tag:blogger.com,1999:blog-14055115.post-3666997436126043952010-07-21T10:18:00.000-04:002010-07-21T10:18:06.394-04:00T4MVC add-in and resource compression updateThe T4MVC add-in and the dot less css add-in add-ins have been officially merged into the chirpy codeplex project. Really love the design time javascript/stylesheet minimization and combination. This is really a great project and one of my favorite add-ins...of course I am not biased in any way. :-)
You can read all about the features of this with Evan Nagle's latest post here. In addition Wayne Brantleyhttp://www.blogger.com/profile/10640873225205821040noreply@blogger.com1tag:blogger.com,1999:blog-14055115.post-19878197396963741032010-03-17T22:59:00.003-04:002010-06-02T10:36:54.283-04:00Style sheet compression and .less add-in...updated with source
6/2/2010 Update - Project enhanced and now on codeplex! http://chirpy.codeplex.com/
Design time minification and .net less for style sheets.Read my previous post on this subject.
http://blog.waynebrantley.com/2009/12/ultimate-automatic-stylesheet-combining.html
Known IssuesIt has been reported that this does not work in 'web site project'. I do not use those anymore, not since they Wayne Brantleyhttp://www.blogger.com/profile/10640873225205821040noreply@blogger.com7tag:blogger.com,1999:blog-14055115.post-32576918293771473352010-03-16T20:12:00.006-04:002011-01-15T10:09:20.903-05:00T4MVC Add-In to auto run template6/2/2010 Update - Project enhanced and now on codeplex! http://chirpy.codeplex.com/
T4MVC is a fantastic solution to avoid 'Magic Strings' in ASP.NET MVC.
Thanks to David Ebbo for this contribution which has made its way to MVCContrib.
Must keep T4 template open and save it once.This has been the only negative thing about the template. I thought about writing an Add-In for VS to do Wayne Brantleyhttp://www.blogger.com/profile/10640873225205821040noreply@blogger.com10tag:blogger.com,1999:blog-14055115.post-61746752754792478872009-12-31T12:49:00.009-05:002010-03-17T23:00:47.525-04:00Ultimate automatic stylesheet combining, minification and .less integration3/17/2010
Update to article here: http://blog.waynebrantley.com/2010/03/style-sheet-compression-and-less-add.html
Combine your stylesheet css files into one file to improve site performance.
We all know this rule, but how do we go about doing this? We could automate this in our build script, but then that means we have to do the same thing in development. So, if you reference 'Wayne Brantleyhttp://www.blogger.com/profile/10640873225205821040noreply@blogger.com15tag:blogger.com,1999:blog-14055115.post-21634716101831207322009-12-07T14:49:00.003-05:002009-12-19T16:24:30.548-05:00ASP.NET MVC 2 Beta EditorFor improvementsASP.NET MVC 2 Beta has some great improvements. One of these improvements is the Html.EditorFor extension. Basically, this extension takes data annotations and types information from your model and uses those to generate editors. You MUST use a strongly typed view to take advantage of this!
I am going to give a brief introduction, just to get to my enhancement - for more information see thisWayne Brantleyhttp://www.blogger.com/profile/10640873225205821040noreply@blogger.com3tag:blogger.com,1999:blog-14055115.post-58818227907833817272009-12-07T12:46:00.000-05:002009-12-07T12:46:05.181-05:00ASP.NET AJAX calling webservice has exception handling bug[This is a re-post from my previous blog]
When using Microsoft ASP.NET AJAX, you can call any webservice you have enabled with the [ScriptService] attribute. This webservice could throw an exception, which ends up on the webpage as a javascript alert. This all works quite nicely, UNTIL you actually deploy such a solution!
Let's say you have a webservice that takes an item and returns Wayne Brantleyhttp://www.blogger.com/profile/10640873225205821040noreply@blogger.com0tag:blogger.com,1999:blog-14055115.post-16233311797354143792009-09-21T11:25:00.004-04:002009-12-07T14:53:43.157-05:00Develop on iPhone with C# and .netIf you have seen Objective-C and did not want any part of it, now there is an alternative!
Use C# and .net on the iPhone with MonoTouch.
Of course you will still need the iPhone SDK and a Mac for development.
9/21 - UPDATE: Screen cast of hello world.Wayne Brantleyhttp://www.blogger.com/profile/10640873225205821040noreply@blogger.com0tag:blogger.com,1999:blog-14055115.post-33911610506915853662009-09-17T11:38:00.001-04:002009-09-17T11:39:04.980-04:00Web Deployment Project Enhancements[Note: This is a republish of a blog I wrote 2/8/2006 on a old blog]Deploying a web project has always required some external software and sometimes manual changes/copying/etc. Thankfully, Microsoft has seen fit to help us with our web deployment scenarios and has created an add-on to Visual Studio 2005 called Web Deployment Project. If you are not familiar with the product, I would suggest Wayne Brantleyhttp://www.blogger.com/profile/10640873225205821040noreply@blogger.com1