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
- 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:
- 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.
- 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:
- Point (i.)
- Disable the button not using the ‘
Enabled
’ property but through HTML attributes (disabled = ‘disabled’
)
- Ensure you attach the ‘
onclick
’ (client script) to your button once you enable it back
-
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)); alert($.inArray(2, arr2)); alert($.inArray("2", arr3)); alert($.inArray(2, arr3)); });
-
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