Thursday, June 7, 2012

Solution for Grid view sorting at client side instead of Server side

Recently during the code review I have identified the performance issue Grid view Server side sorting . To avoid the server side sorting I have implemented

client side sorting using jQuery plugin. Here is the implementation steps for Client side sorting.

Step#1

=>Download the tablesorter plugin min JavaScript and place into script folder

=>Add the reference to sorting required page

Ex:

<script src="../Scripts/jquery.tablesorter.min.js" type="text/javascript"></script>

Add this script into JavaScript block



$(document).ready(function () {
$("#ctl00_ContentPlaceHolder_gvMyStyles").tablesorter(); 
});

Step#2

Place these two lines of code after the gridview bind



gvMyStyles.UseAccessibleHeader = true;  
gvMyStyles.HeaderRow.TableSection = TableRowSection.TableHeader; 
 

Saturday, May 12, 2012

My First cloud app is up and running .

                  I am very excited to announce this. My first cloud application is up and running .Click here  to navigate the site. A couple of days ago I have started developing a cloud app using Microsoft windows Azure platform. I named it as "SketchIt". It's really makes some fun.

What is SketchIt :     
               SketchIt is a Pencil sketch drawing Application. You can choose your photo and click on "Upload". That’s it . SketchIt automatically   draws your photo with pencil using a powerful pencil sketch engine .It also shows drawn image preview and URL to download your  pencil sketched image .

SketchIt
       
How it works :        
             SketchIt uses a powerful engine called “Vedhasi”. I have developed this engine and named it as "Vedhasi" . Sketchit is hosted  in Microsoft cloud platform with  two web roles so it is 100% reliable no down time.So start draw your photo with SketchIt..

Thursday, May 3, 2012

The 3+3+3 will not creates lot of strings

A couple of days ago during the code review i have observed lots of interesting things. One of the important thing is when to use String builder and when not to use String Builder.

                 There are so many difference between String and String Builder.  Any way i don't want to cover all the things here because it going to rewriting the same code again. But here i am going clear the confusion about  String or String Builder during the concatenation.
                

String Builder comes with its own overhead. If you have fewer than about seven concatenations, Use simple string concatenation even if you get intermediate strings on the heap.Secondly, when concatenating strings in one shot, only the final string is created. In that case, do not use String Builder


Ex: String s = “s1” +” s2” + “s3” + “s4”;

String Builder capacity

The String Builder  default capacity is 16. Each time the String Builder runs out of capacity, it allocates a new buffer of twice the size of the old buffer

StringVsStringBuilder

Thursday, April 12, 2012

Replacing backslash in a string

 

 

 

 string userName = "Smith \"Fake Lastname \"";
            userName = userName.Replace("\"", "");

Monday, January 23, 2012

Identifying the form is valid in ASP.NET MVC using jQuery

Identifying the form is valid in ASP.NET MVC using jQuery
 if ($(document.forms[0]).valid() == false) {
        alert(val.valid());
        return; 
    }

 


Blogger Labels: jQuery

Wednesday, January 11, 2012

Disable submit button after user click using jQuery

Recently i have got a requirement to disable  the submit buttons Once it is clicked so that user should not click more than once.

 
                $("input[type='submit']").each(function () {
                    
                        $(this).attr("disabled", "disabled");
                });

Writing above code in button click you can disable all the submit buttons once user click any submit button in the form.  But some browsers  you cannot submit a form if you disable the button on  click event.

Here is the solution which works all the browsers  :



//Disable all the submit buttons when user click on any submit button
function DisableSubmitButtons( clickedButton) {
    $("input[type='submit']").each(function () {
        if (this.name != clickedButton)
            $(this).attr("disabled", "disabled");
        else {
         //hiding the actually clicked button
            $(this).hide();
            //Creating dummy button to same like clicked button
            $(this).after('<input type="button" disabled="disabled" value="' + $(this).val() + '" class="' + $(this).attr('class') + '" />');
        }
    });
}

This code disables all the submit buttons and hide the clicked button and put a new disabled button in it's place.


You can call this function with passing the clicked button Id


Example :Here is the example snipped code to call DisableSubmitButton function in Save button click



$('#btnSave').click(function(){
//I have hard coded to easily understand you can pass dynamically
  DisableSubmitButtons("btnSave");
});