Wednesday, December 31, 2008

How to enable Select, Delete, Update for ObjectDataSource without a SQL database support

http://vinull.com/Post/2007/04/16/aspnet-gridview-and-objectdatasource-wi.aspx

Default values for C# data types

bool: False
byte: 0
char:
decimal: 0
double: 0
float: 0
int: 0
long: 0
object:
short: 0
signed byte: 0
string: null
unsigned int: 0
unsigned long: 0
unsigned short: 0
int?: null

what is the order of the events handling in master page and content page?

If ContentPage derives from BasePage and uses a Master page. The following is the sequence in which events occur when a master page is merged with a content page:

BasePage.Ctor

Content page Ctor

Content page PreInit event.

Master page controls Init event.

Content controls Init event.

Master page Init event.

Content page Init event.

Content page Load event.

Master page Load event.

Master page controls Load event.

Content page controls Load event.

Content page PreRender event.

Master page PreRender event.

Master page controls PreRender event.

Content page controls PreRender event.

Master page controls Unload event.

Content page controls Unload event.

Master page Unload event.

Content page Unload event.


http://msdn.microsoft.com/en-us/library/dct97kc3.aspx.

Tuesday, December 23, 2008

How to hide control using javascript?

The answer written in the first response is not actually 100% accurate.

We can hide/display the controls using

1) document.getElementById("").style.display="none"/document.getElementById("").style.display="inline"

or

2)
document.getElementById("").style.visibility="visible";/document.getElementById("").style.visibility="hidden";

The difference between the two is using the 1st option, we can hide the control and the space occupied by the controls also gets
removed, i.e if the controls has a certain height and is contained in a table row, the row gets collapsed and when displayed, the control will again take it's place.and the row will again retain its height by displaying the control in it.

On the other hand if we use 2nd option, the control will get hide
but the space occupied by the control will remain as it is and the row will not collapse, i.e the row will still be displayed
as blank containing the control in hidden mode.

From http://www.dotnetspider.com/resources/6563-How-hide-control-using-javascript.aspx

Sunday, December 14, 2008

Why I do not use the onunload for leaving page warning?

When onunload is fired, you cannot cancel the leaving to stay on the original page.

Why I do not use the popup dialog of onbeforeunload for leaving page warning?

Quote from http://msdn.microsoft.com/en-us/library/ms536907(VS.85).aspx:

"
function closeIt()
{
return "Any string value here forces a dialog box to \
appear before closing the window.";
}
window.onbeforeunload=closeIt;

When a string is assigned to the returnValue property of window.event, a dialog box appears that gives users the option to stay on the current page and retain the string that was assigned to it. The default statement that appears in the dialog box, "Are you sure you want to navigate away from this page? ... Press OK to continue, or Cancel to stay on the current page.", cannot be removed or altered.
"

My experience is that the default string "Are you..." cannot be localized. This is the reason why I do not use in my portal.