Friday, August 31, 2007

Firing/Invoking Multiple Javascript fuctions on body onload

Often we land up in a scenario, where we require to invoke more than 2 javascript functions on Page Load.
We can call one function straight away by calling a function on 'onload' event of body tag. 2nd function u can invoke by overriding Render event of page life cycle. You can over-ride 'Render' event as below.
protected override void Render (HtmlTextWriter writer)
{
    base.Render (writer);
    writer.Write("");
}
Note:
Developers often try to achieve the same functionality by calling javascript function as below.
    Response.Write("");
It results in an error, because "Response.Write" tries to call the function even before page load happens, hence it can't find/locate required javascript fuction in page, which results in an error.

Friday, July 13, 2007

Creating JavaScript Member functions

Syntax for creating your member functions in JavaScript

String.prototype.FunctionName = function()
{
// write your logic;
return 'return value';
}

You can convvert above mentioned ToAscii fuction as member function, Thats left for the readers for practice.

Here are some frequently used functions.
Examples:
1.Trim
String.prototype.Trim = function()
{
return this.replace(/^\s+|\s+$/g,"");
}
2.Ltrim
String.prototype.Ltrim = function()
{
return this.replace(/^\s+/,"");
}
3.Rtrim
String.prototype.rtrim = function()
{
return this.replace(/\s+$/,"");
}

Monday, October 09, 2006

Why do Oracle commits when we issue a DDL statement?

In DDL operation, DDL locks wiil be taken place automatically against the respective object. So one needs to remove the locks as soon as the statement got executed, it can be achieved by commiting the transaction. The next Question is what if the transaction fails. the answer is oracle simply rollback.The next complication is if it rollback, user looses their transactions that happend just before the DDL statement.Thats why Oracle executes a commit statement just before the DDL also. Thats the reason why the end user transactions will be committed irrespective of the success of DDL. A DDL statement actually execute as below
commit;
DDL
commit;
Exception
rollback