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);
Equal:
var test = (x == null) ? x : 100;



Reference:

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">
    <contenttemplate>
         <asp:GridView  runat="server"/>
    </contenttemplate>
</asp:UpdatePanel>
 -          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
event
    $(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();
             prm.add_initializeRequest(prm_InitializeRequest);
             prm.add_endRequest(prm_EndRequest);
            
             function prm_InitializeRequest(sender, args) {
                 var panelProg = $get('divImage');                
                 panelProg.style.display = '';
             }

             function prm_EndRequest(sender, args) {
                 var panelProg = $get('divImage');                
                 panelProg.style.display = 'none';
             }
         </script>

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


SCRUM, one of agile methodologies


Keyword: iterative, incremental
Reference:
http://en.wikipedia.org/wiki/Scrum_%28development%29

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;





  • http://www.geekm.ag/Archive/Good_code_is_cheap_code