Click here to Skip to main content
13,287,856 members (36,558 online)
Click here to Skip to main content
Add your own
alternative version


2 bookmarked
Posted 21 Apr 2011

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

, 21 Apr 2011
Rate this:
Please Sign up or sign in to vote.
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('<h1>Sample \'StringBuilder\' HTML</h1>');

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.


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


About the Author

United Kingdom United Kingdom
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralRe: To follow the culinary model, why use a 'Death Star' to crac... Pin
GladToBeGrey23-Apr-11 22:39
memberGladToBeGrey23-Apr-11 22:39 
GeneralRe: I think I already answered your question. Yours is an altern... Pin
Albin Abel23-Apr-11 7:12
memberAlbin Abel23-Apr-11 7:12 
GeneralReason for my vote of 5 Good solution. Pin
Prasanta_Prince22-Apr-11 4:26
memberPrasanta_Prince22-Apr-11 4:26 
GeneralReason for my vote of 5 Practical alternative with some good... Pin
AspDotNetDev21-Apr-11 11:51
protectorAspDotNetDev21-Apr-11 11:51 
GeneralTo answer your question "why not", the implementation of the... Pin
AspDotNetDev21-Apr-11 11:50
protectorAspDotNetDev21-Apr-11 11:50 
GeneralThe question "Why not" is not relevant. Your method has adva... Pin
Albin Abel21-Apr-11 8:19
memberAlbin Abel21-Apr-11 8:19 
GeneralRe: No, my question is why create a dependency on ASP and AJAX a... Pin
GladToBeGrey22-Apr-11 8:21
memberGladToBeGrey22-Apr-11 8:21 
No, my question is why create a dependency on ASP and AJAX at all when there's really no need to? If OOP purity is your requirement, then create a stringBuilder class based on the above, which is then OO and extensible. In fact, I since found some examples where others have done just that. E.g.:

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171207.1 | Last Updated 21 Apr 2011
Article Copyright 2011 by GladToBeGrey
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid