If you need to pass small amounts of data from one page to another, you can pass it in the query string and the target page can retrieve it through Request.QueryString collection (GET operation). However, if you need to pass large amount of data you cannot pass it in the query string since Internet Explorer has maximum 2048 character limit on the address of the page. In these cases, you can pass data from one page to another using POST operation.


In your source page, define a hidden variable to hold the data to pass and pass only its ID to the target page in the query string.


The target page should first get that ID through Request.QueryString collection.
Then it should set its own hidden variable value with the one in the source frame on
the client-side during BODY onload event handler. You can use opener object on the
client-side to retrieve the DOM elements in the opener page. Then it should do a
postback to itself and retrieve the value of its hidden variable through Request.Form
collection.


Source Page JavaScript



function PassData(ctlID)
{
window.open('TargetPage.aspx?ctlID=' + ctlID, 'NewWindow','width=400,height=300,location=no,menubar=no,resizable=no,scrollbars=no,status=yes,toolbars=no');
}

Source Page ASPX



<asp:TextBox ID="txtPassData" runat="server" Text="Data to pass"
CssClass="TextBox"></asp:TextBox>
<asp:Button ID="btnPassData" runat="server" Text="Pass Data"
CssClass="Button" OnClientClick="PassData('txtPassData'); return
false;" />

Target Page JavaScript


function Body_Onload() 
{
var pageStatusElem = document.getElementById('hfPageStatus');
// Page status hidden field value is initially empty string
if (pageStatusElem.value == '')
{
// Set text to spell check hidden field value to the text in the opener window
document.getElementById('hfTextPassed').value = opener.window.document.getElementById('<%=Request.QueryString["ctlID"]% >').value;
// Set page status hidden field value so that when the page is posted back it can process text to spell check retrieved from the opener window
pageStatusElem.value = '<%=SET_TEXT%>';
// Post back the page
document.form1.submit();
}
}

Target Page ASPX


<body onload="Body_Onload()">
<form id="form1" runat="server">
<div>
Text passed: <asp:Label ID="lblTextPassed" runat="server"
Text="Label"></asp:Label>
</div>
<asp:HiddenField ID="hfTextPassed" runat="server" Value="" />
<asp:HiddenField ID="hfPageStatus" runat="server" Value="" />
</form>
</body>

Target Page C#



public const string SET_TEXT = "SetText";
public const string TEXT_IS_SET = "TextIsSet";
protected void Page_Load(object sender, EventArgs e)
{
// Initial entry
if (hfPageStatus.Value == SET_TEXT)
{
// Set page status not to enter again
hfPageStatus.Value = TEXT_IS_SET;
}
lblTextPassed.Text = hfTextPassed.Value;
}