Sunday, 15 June 2014

c# - newlines are ignored in javascript for asp.net multiline textbox -



c# - newlines are ignored in javascript for asp.net multiline textbox -

i have multi line textbox on asp.net form , calling next javascript function on past event.

new lines ignored if paste data.

i don't know if javascript function. can see '/n' in inner text somehow not beingness rendered properly. "hello\nworld" beingness rendered "hello world"

function handlepaste(textbox, e, label, len) { var savedcontent = textbox.innerhtml; if (e && e.clipboarddata && e.clipboarddata.getdata) {// webkit - info clipboard, set editdiv, cleanup, cancel event if (/text\/html/.test(e.clipboarddata.types)) { textbox.innerhtml = e.clipboarddata.getdata('text/html'); } else if (/text\/plain/.test(e.clipboarddata.types)) { textbox.innerhtml = e.clipboarddata.getdata('text/plain'); } else { textbox.innerhtml = ""; } waitforpastedata(textbox, savedcontent); if (e.preventdefault) { e.stoppropagation(); e.preventdefault(); } homecoming false; } else {// else - empty editdiv , allow browser paste content it, cleanup textbox.innerhtml = ""; waitforpastedata(textbox, savedcontent, label, len); homecoming true; } } function waitforpastedata(elem, savedcontent, label, len) { if (elem.childnodes && elem.childnodes.length > 0) { processpaste(elem, savedcontent, label, len); } else { = { e: elem, s: savedcontent } that.callself = function () { waitforpastedata(that.e, that.s, label, len) } settimeout(that.callself, 20); } } function processpaste(textbox, savedcontent, label, len) { pasteddata = textbox.innerhtml; if (savedcontent.length > 0) { textbox.innerhtml = savedcontent + pasteddata ; } if (pasteddata.length > len) { textbox.value = textbox.value.substring(0, len); document.getelementbyid(label).classname = "red-text"; document.getelementbyid(label).innerhtml = 'you trying type much info '; } else { document.getelementbyid(label).classname = "grey-text"; document.getelementbyid(label).innerhtml = textbox.value.length.tostring() + ' of ' + len + ' chars'; } }

probably because html doesn't render new lines way you're expecting. seek <br> instead.

javascript c# asp.net vb.net

No comments:

Post a Comment