Best Practices Development for Silverlight - MVVM

Posted on: Wed Jun 09 15:06:32 -0700 2010. Updated on: Thu Jun 10 16:51:14 -0700 2010.
Category: Silverlight

If you're using silverlight to develop apps, you "should" follow the MVVM pattern, ie Model-View ViewModel. It is basically the pattern for databinding between your data Model and the View. Remember, it is just a recommended pattern, and everything else are helpers. It is OK to have code in your code-behind, but this should be kept to a minimal, and ideally most stuff of your business logic is abstracted out to the model.

Here is a great link to get started and learn more: MVVM Light Toolkit
I very much recommend watching his video from MIX 2010.

Using the application Web Cache

Posted on: Sat Jun 05 17:09:31 -0700 2010. Updated on: Sat Jun 05 17:13:22 -0700 2010.
Category: DotNet

It is a good idea to use caching for frequently accessed objects to reduce trips to the database or your web services. Here is an example of using the System.Web application cache. You can even use this in dll's outside of your web project, as long as you reference System.Web.

string cacheName = "objectNameCache";
int cacheDurationMinutes = 10;
var cache = System.Web.HttpRuntime.Cache;
			
cache.Insert(cacheName, quote, null, DateTime.UtcNow.AddMinutes(cacheDurationMinutes), TimeSpan.Zero);

// now to access it... First check if null, then simply cast cache to outcoming object.
if (cache[cacheName] != null)
{
    quote = (DataTransferObjects.QuoteData)cache[cacheName];
}

Sitefinity RadEditor Adding Custom Styles

Posted on: Thu May 27 16:23:45 -0700 2010. Updated on: Thu May 27 16:26:19 -0700 2010.
Category: Telerik Controls and Sitefinity

The first thing you should do in your App_Themes/YourThemeName/ is have your styles seperated out into two files. One that would be included in the rad editor as well as your page and one that would be only for your site. The reason is that you don't want some weird body styles getting applied inside the rad editor.

Once you have that done, simply edit one of the following files:
/Sitefinity/Admin/ControlTemplates/EditorToolsFile.xml

This is the ToolsFile that is included in the radeditor ie. for Generic COntent editing. Now, you can add a css files node under the root node like this:


    
  

You can also modify this same file under the classes node and add in which styles should be available to the end user while editing in the RadEditor. There should already be an example in here.

Get Enum from matching string

Posted on: Wed May 19 13:19:08 -0700 2010. Updated on: Wed May 19 13:19:08 -0700 2010.
Category: DotNet

Getting the enum from the int representation of it is pretty easy, but you can't do the same kind of cast when you want to go from a string representation to the enum.

this link explains it weill: http://blogs.msdn.com/tims/archive/2004/04/02/106310.aspx

Deploy VS Database Projects workaround

Posted on: Tue May 18 12:27:06 -0700 2010. Updated on: Tue May 18 12:27:06 -0700 2010.
Category: DotNet

I like using the Visual Studio Database Projects to keep track of my databases in a particular project. The thing is, when deploying a brand new database, using it can be a bit not cool because there is no Deploy button. You have to go into the project properties, change the deploy action to actually push to the database, then you have to make sure the connection to the database works, and if you're using source control, you probably do not want to check in a build that deploys to the database every time.

So the workaround is:
1. Right click the project, and hit deploy, of course without pushing to the DB.
2. Look at the output window in VS at the bottom, and copy the location of the deploy script generated
3. Open up SQL Server management studio and hit File -> Open File and paste in the path.
4. Be sure you are in the right DB instance, and now you'll need to do some text replacing. Replace $(DatabaseName) in the whole document for you db name.
5. Then delete the lines of code at the top that have the colen :
6. Now hit run

Response.Redirect open new window

Posted on: Thu May 06 18:27:48 -0700 2010. Updated on: Thu May 06 18:27:48 -0700 2010.
Category: DotNet

Sometimes we need a button action or something during the postback to pop open a new window / tab using the very known Response.Redirect. This is easy to do, simply add OnClientClick="aspnetForm.target ='_blank';" in the button's property.

Find out more at this site: http://dotnetchris.wordpress.com/2008/11/04/c-aspnet-responseredirect-open-into-new-window/

Ads

Categories

About

Random foliage

This website is meant to be a reference for ASP Dot Net developers. The entries are a compilation of things I've figured out how to do and that I deem useful to keep of track for future reference. Assumptions: web development with: C Sharp (vb sucks), visual studio 05/08, .net 3.5, meant for programmers. Written by: James Reategui.