Thursday, 1 December 2011

Selectable Themes in MVC3 with JQuery, Ajax

This is a quick and possibly dirty way of getting selectable themes with MVC. This could be expanded to be used with profiles or post logon events.It is a good starter. Also I'm sure this could be done entirely in JQuery but getting the info to the controllers might be handy under some circumstances.

Add Selection on Session on the _layout.cshtml or masterpage

Then we need a dropdown (select) and some JQuery to select it.

Then we have the controller code which saves the session variable 

OK you could have done all this with JQuery as discussed before, but putting stuff to and fro between MVC and html is fairly interesting and as I said opens the usage for saving this to a database and user profile. 

No comments:

Post a Comment

Comments are welcome, but are moderated and may take a wee while before shown.