Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Some Important Findings - Web Applications: Part II

0.00/5 (No votes)
17 Jul 2012 1  
Continuing from last upload about some useful findings

Introduction

I am sharing some important findings I got from some of my earlier work. Hope these will help some of my developer friends and also help me in summarizing findings for my work in the future.

Using the Code

  1. When Button is disabled in page_load, then its onclientclick is not rendered.

    Suppose you have a button and it specifies ‘OnClientClick’ value but as per your logic you have disabled it from server side (loading stage).

    After this, you will face either of the following scenarios:

    1. If ‘OnClientClick’ value was specified either in mark up or will happen (set) always and you are enabling the disabled button after a post back, then everything will work properly.
    2. If you are enabling the disabled button from client script, then the client handling part of that button will not work.

      For resolving the above point, either follow:
      1. Point (i.)
      2. Disable the button not using the ‘Enabled’ property but through HTML attributes (disabled = ‘disabled’)
      3. Ensure you attach the ‘onclick’ (client script) to your button once you enable it back

  2. Using ‘$.inArray

    We use this method to determine whether something exists in the specified array or not but many times it fails to return the expected result. The main cause is with the type of input demanded. Consider the below example:

     $(document).ready(function () {
                var arr1 = new Array();
                var arr2 = new Array();
                var arr3 = new Array();
    
                arr1["one"] = "1";
                arr1["two"] = "2";
                arr1["three"] = "3";
    
                arr2[0] = 1;
                arr2[1] = 2;
                arr2[2] = 3;
    
                arr3["0"] = "1";
                arr3["1"] = "2";
                arr3["2"] = "3";
    
                alert($.inArray("2", arr1)); // returns -1
                alert($.inArray(2, arr2)); // returns 1
                alert($.inArray("2", arr3)); // returns 1
                alert($.inArray(2, arr3)); // returns -1
            });
  3. Wrapping text in any HTML parent tag. I used one CSS property (CSS 3) for ensuring that text is wrapped within a DIV.

    style="word-wrap:break-word;"

    It will ensure that it breaks all long words and wraps onto the next line.
    However since it is specific to CSS3, while using Visual Studio, you may face some warnings but it works well in all major browsers.

History

  • 15/07/2012: First revision

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here