Encoding of the Multirow Textbox content in the HTTP request

Damir Dobric Posts

Next talks:



Follow me on Twitter: #ddobric




When using of the multi-row TextBox ASP.NET control, sometime it is required to send the content of that box to server.

For example the request http://host/myapp/default.asp?textboxcontrol=prm

can be created with the javascript as shown:


var prm = document.all[“myTextControl”].innerHTML;


window.showModalDialog(“http://host/myapp/default.asp?textboxcontrol=.” +



On the server side the request can be read as follows:


string prm = Request[“textboxcontrol”] as string;


This all is very easy to perform. However the example above will not work if the content of the control is a text consisted of many rows.

For example, the text





will be decoded on the server side as: row1+row2, which is obviously not the expected value.

To ensure that the text is decoded properply the content of the textbox has to be encoded propely at the client side. The right solution would look as shown here:


var prm = escape(document.all[“myTextControl”].innerHTML);


In this case the server receives the request, which contains all required and properly encoded information: row1+%0d%0arow2

Posted Aug 17 2006, 02:09 PM by Damir Dobric
Filed under:
developers.de is a .Net Community Blog powered by daenet GmbH.