Thursday, September 27, 2007

Send Values to Popup window with unlimited length - Javascript

Usually passing values to popup window using querystring in client side script. But using querystring we can pass value with 2083 chars limit.

Using Parameter values we can pass more than 4000 chars to popup screen.

Page1.aspx

var winArgs = escape(document.getElementById('txtVal').value);
var winSettings = 'center:yes;resizable:no;help:no;status:no;dialogWidth:250px;dialogHeight:200px';
window.showModalDialog("popup.aspx", winArgs, winSettings);

txtVal is textbox ID.

The escape() function encodes a string, so it can be read on all computers.

popup.aspx

var par = window.dialogArguments;
document.getElementById('txt').value =unescape(par);

Here get the parameter value and assign it into textbox. txt is textbox ID.

The unescape() function decodes a string encoded with escape().


No comments: