Tuesday, November 24, 2009

"String Builder" function in Javascript using Ajax(Enabling Scriptmanager).

I have come across new functionality called "stringbuilder" in javascript using Ajax.

please follow the below steps to enable the Stringbuilder.

Step 1:

Add script manager tag in the aspx page.


Step 2:

Example:

<script type="text/javascript">
function buildAString(title)
{
var headTagStart = "";
var headTagEnd = "";
var titleTagStart = "";
var sb = new Sys.StringBuilder(this._headTagStart);
sb.append(titleTagEnd);
sb.append(title);
sb.append(titleTagEnd);
sb.append(headTagEnd);
// Displays: "The result: "
alert("The result" + sb.toString());
}
var title = "A Title";
buildAString(title);
</script>