Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

Javascript StringBuilder for Beginners (ASP.NET 3.5 and above)

5.00/5 (2 votes)
21 Apr 2011CPOL 18.6K  
Why not simply:markup = [];markup.push('');markup.push('');markup.push('');markup.push('');markup.push('Sample 'StringBuilder' HTML');markup.push('');markup.push('');alert(markup.join('nr'));markup.toString() could...
Why not simply:

XML
markup = [];

markup.push('<html>');
markup.push('<head>');
markup.push('</head>');
markup.push('<body>');
markup.push('<h1>Sample \'StringBuilder\' HTML</h1>');
markup.push('</body>');
markup.push('</html>');

alert(markup.join('\n\r'));


markup.toString() could also be used if there is no need to add any separator. Uses native Javascript with no need for AJAX, or ASP.NET. Should therefore work cross-platform and cross-browser.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)