Blogger Widgets
  • Sharing Photos using SignalR
  • TFS Extenstion - allows copy work items between projects
  • Displaying jquery progressbar with ajax call on a modal dialog
  • Managing windows services of a server via a website
  • Exploring technologies available to date. TechCipher is one place that any professional would like to visit, either to get an overview or to have better understanding.

Search This Blog

Monday 27 February 2012

Assigning default value for fields of type string using Fluent NHibernate

Fluent hibernate provides various decent methods that allow you to map class members with table fields. I have tried using the .Default() method while mapping which works fine for numbers but for string datatype this is not working.

So have looked into the actual execution of sql which looks like (ie.. I have added a new member to the class and want all exists rows to have a default value)

update dept
set location = Manchester

Then I have realised single quote(') were missing for the value which should look like

update dept
set location = 'Manchester'

Now I have updated my mapping as follows

Map(x => x.location).Default("'Manchester'").Not.Nullable();

Never trust anything that can think for itself if you can't see where it keeps its brain.
~J.K. Rowling

Wednesday 15 February 2012

Guidelines for Optimising ASP.NET Websites

Optimisation is one of the most challenging task for any website. Optimisation should be planned just like any development task so as to avoid spending more time towards the end of project. There are various elements that needs to be considered during this process, here is the list below:-

1. Reduce number of requests made to the server by using minification of stylesheets(.css) and javascript code(.js)

2. Combining all resources and deliver zipped verion (using GZIP)

3. Prefer GET than POST for ajax calls

4. Prioratise loading of resources and use lazy loading

5. Be cautious about references to resources and remove unwanted/unavailable references (No 404)

6. Use image maps as opposed to independent images(.jpeg,.gif etc)

7. Use caching for static components such as images

8. Make Ajax calls cachebale

9. Try using external scripts & css whereever possible (use CDN)

10. Reduce cookie size and also make cookieless request for resources such as images

There are various tools/plugins/extensions that are freely available, these can help you point out optimisation issues relating to your website. But each of these tools use different sets of rules and provides different types of statistics. Here is the short list:-

All of the biggest technological inventions created by man - the airplane, the automobile, the computer - says little about his intelligence, but speaks volumes about his laziness.
Mark Kennedy

Tuesday 14 February 2012

JQGrid Autoheight not working on IE 8 and IE 9 compatibility

JQGrid autoheight works well if you have less number of columns that fit inside a browser window, but if your grid has too many columns with a horizontal scroll bar then you might have an issue. I have been using JQGrid "forceFit" parameter that generates a a horizontal scroll bar in order to display all columns which is great and mostly all browser. But IE 8 & IE 9 compatibility view does display a vertical scroll bar.

So the following snippet can be used to fix this:

var GBDIV = jQuery('#invoicesGrid').parents('.ui-jqgrid-bdiv');
if(GBDIV.length > 0) {
  var hvScroll= GBDIV[0].scrollHeight > GBDIV[0].clientHeight;
  if(hvScroll){
    var gridHeight = jQuery('#invoicesGrid').height();
    jQuery('#invoicesGrid').setGridHeight(gridHeight + rowHeight);
  }
}

The above code should be added to "loadComplete" event of your JQGrid

A computer would deserve to be called intelligent if it could deceive a human into believing that it was human. Alan Turing Read more: http://www.brainyquote.com/quotes/keywords/computer.html#ixzz1mMy5nFqD

Handling JQGrid Autoheight on last page that has "rownum" less than "reccount"

One of the nice feature that JQGrid provides is enabling auto height using setGridHeight("100%"). This feature works fine except if the "number of rows on the current page" is less than "rows per page" which is last page, since it sets height to "100%" the height of the page is suddenly reduced.

Here is the sample screenshots taken from JQGrid demo website (goto Advanced -> Resizing)

First Page :

Last Page :

You wouldn't want this to happen if you got some more content after the grid. So now here is how you can fix this :-

loadComplete: function(data) {
   var rcPage = jQuery('#invoicesGrid').getGridParam('reccount');
   var rpPage = jQuery('#invoicesGrid').getGridParam('rowNum');                                
   var rowHeight = $('#invoicesGrid .ui-row-ltr').eq(0).height();
   if(rcPage < rpPage) {                                    
      if(rowHeight){
         var gridHeight = (rpPage * rowHeight);
         gridHeight += 10;  //row header height         
         jQuery('#invoicesGrid').setGridHeight(gridHeight);
      }
   }
   else {
      jQuery('#invoicesGrid').setGridHeight('100%');
   }
   jQuery('#invoicesGrid').setGridParam('scrollOffset',0);
}

Just hook up this code to your jqgrid and this should do the trick.

A computer once beat me at chess, but it was no match for me at kick boxing. Emo Philips
Copyright © 2013 Template Doctor . Designed by Malith Madushanka - Cool Blogger Tutorials | Code by CBT | Images by by HQ Wallpapers