public virtual T GetQueryString<T>(string name)
{
string queryParam = null;
if (Request.QueryString[name] != null)
queryParam = Request.QueryString[name];
if (!String.IsNullOrEmpty(queryParam))
return (T)TypeDescriptor.GetConverter(queryParam.GetType()).ConvertFrom(null, Thread.CurrentThread.CurrentCulture, queryParam);
return default(T);
}
Saturday, 19 May 2012
Get Querystring Parameter
Wednesday, 16 May 2012
Read a property from Active Directory
public static string GetUserProperty(string user, string propertyName)
{
using (var context = new PrincipalContext(ContextType.Domain, “yourDomainName”)
{
UserPrincipal userPrincipal = new UserPrincipal(context);
userPrincipal.SamAccountName = user;
PrincipalSearcher principalSearcher = new PrincipalSearcher();
principalSearcher.QueryFilter = userPrincipal;
Principal searchResults = principalSearcher.FindOne();
if (searchResults != null)
{
return searchResults.GetProperty(propertyName);
}
}
return string.Empty;
}
Monday, 14 May 2012
ASP.NET MVC 3 Aspect Oriented Programming with Castle Interceptors
http://cangencer.wordpress.com/2011/06/02/asp-net-mvc-3-aspect-oriented-programming-with-castle-interceptors/
http://blog.andreloker.de/post/2009/02/20/Simple-AOP-integrating-interceptors-into-Windsor.aspx
Turn off enclosing tags in CKEditor
ckeditor/config.js
CKEDITOR.editorConfig = function( config )
{
config.enterMode = CKEDITOR.ENTER_BR;
config.shiftEnterMode = CKEDITOR.ENTER_BR;
};