developers.de
daenet's .NET Community

Encoding of the Multirow Textbox content in the HTTP request

Damir Dobric Posts

 

Damir@Phone    



My upcoming sessions:

AppFabric Applications at
NRW Conf 2011
09.Sept.2011 Wuppertal

HTML5 widgets in WP7+
Monodroid
Mobility Day
21.Sept.2011 - Zagreb

AppFabric and WCF sessions at
Advanced Developer Conference
26.-27. Oktober 2011 in Frankenthal

AppFabric Applications, queues, topics and more at
Prio Conference
02. - 03. November 2011 in Meistersingerhalle Nürnberg

AppFabric Applications deep dive hosted by
.NET User Group Frankfurt
17.Nov.2011 18.30-22.30 Microsoft - Bad Homburg 

 

 

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=.” +

prm,..);

 

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

 

“row1

row2”

 

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:

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
daenet GmbH