Saturday, 19 May 2012

Get Querystring Parameter

 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);
}

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

Dynamic Proxy Tutorial

http://kozmic.pl/dynamic-proxy-tutorial/

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;
};

Friday, 30 March 2012

LinkButton - Not firing click event in second time

http://theway2sharepoint.blogspot.com/2012/03/linkbutton-not-firing-click-event-in.html

 

<script type="text/javascript">

function setFormSubmitToFalse()
{
_spFormOnSubmitCalled = false;
return true;
}

</script>

<asp:LinkButton ID="btnDate" runat="server" HtmlEncode="false" CommandName="Download" CommandArgument="<%# ((GridViewRow) Container).RowIndex %>" Text='<%# Eval("Date")%>' OnClientClick="javascript:setFormSubmitToFalse();"></asp:LinkButton> 

Monday, 12 March 2012

Get querysytring parameter with javascript

function getQuerystring(key, default_)
{
  if (default_==null) default_="";
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
}

Reference:http://www.bloggingdeveloper.com/post/JavaScript-QueryString-ParseGet-QueryString-with-Client-Side-JavaScript.aspx