Wednesday, March 16, 2011

How to check if an argument is not a number in Javascript

isNaN function
Evaluates an argument to determine if it is not a number.
isNaN("string") //returns true
isNaN("12") //returns false

Null-coalescing operator, Double question mark( ??) in C#

        int? x = null;
        Console.WriteLine(x?? 100);
var test = (x == null) ? x : 100;


How to show a heavy-data gridview not in page load, to prevent freezing page?

 -          Put gridview into a Update panel
<asp:UpdatePanel ID="UpdatePanelMemberList" runat="server" UpdateMode="Conditional">
         <asp:GridView  runat="server"/>
 -          Add a hidden field to let client side javascript to click button for showing  gridview
 <asp:HiddenField ID="H1" runat="server" />
After page loaded in html trigger button click
    $(document).ready(function () {
        var hidenv = $("#<%=H1.ClientID %>").val();
        if (hidenv != 'show'return;
         $("#<%=Submit.ClientID %>").trigger('click');

How to show progress in ASP.NET WebForms by UpdatePanel

         <script type="text/javascript">
             var prm = Sys.WebForms.PageRequestManager.getInstance();
             function prm_InitializeRequest(sender, args) {
                 var panelProg = $get('divImage');                
        = '';

             function prm_EndRequest(sender, args) {
                 var panelProg = $get('divImage');                
        = 'none';

        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <div id="divImage" style="display:none">
                     <asp:Image ID="img1" runat="server" ImageUrl="~/images/progress.gif" />
                <br />
                <asp:Button ID="btnInvoke" runat="server" Text="Click"
                    onclick="btnInvoke_Click" />

SCRUM, one of agile methodologies

Keyword: iterative, incremental

Good code is cheap code

  •    Plan your code to be cheap:
    • Use patterns where they are going to be beneficial and will save you time;
    • Ignore the patterns that will not (e.g. when was the last time you ported a system to a different DB?);
    • Use frameworks where appropriate to speed up development;

  • Refactor when required, don’t get ahead of yourself;