65.9K
CodeProject is changing. Read more.
Home

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

starIconstarIconstarIconstarIconstarIcon

5.00/5 (2 votes)

Apr 21, 2011

CPOL
viewsIcon

18648

Why not simply:markup = [];markup.push('');markup.push('');markup.push('');markup.push('');markup.push('Sample \'StringBuilder\' HTML');markup.push('');markup.push('');alert(markup.join('\n\r'));markup.toString() could...

Why not simply:
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.