Interaction between 2 webforms

  • Thread starter Thread starter Anita C
  • Start date Start date
A

Anita C

I have a webform- MainForm.aspx, which has a button amongst others on
clicking which a new window with a webform
opens(this.RegisterStartupScript("Browse Custom Reports Folder","<script
language='javascript'>window.open('ReportsFolderExplorer.aspx', '_blank',
'width=450,height=200,scrollbars=yes,resizable=yes');</script>");

In the webform - ReportsFolderExplorer.aspx the user can select a value from
a grid, which on a buttonclick needs to be passed back to populate
txtReportName in MainForm.aspx. The window which houses
ReportsFolderExplorer.aspx needs to be closed too.

How do I achieve the above.
Thanks in advance.
 
You'll need to do this using JavaScript in the new window. You can access
the opening page using the window.opener property.

For example, in the ReportsFolderExplorer.aspx file, you'd have a javascript
function:

function updateReportName(reportName)
{
if (!window.opener)
{
alert("Could not find window opener");
return;
}
window.opener.updateReportTextField(reportName);
}

On each report, you'd need to add an onClick handler (client-side),
referencing this function, and passing in the filename of the current report
as a parameter.

....and in MainForm.aspx, you'd have the javascript:

function updateReportTextField(reportName)
{
document.forms["Form1"].elements["txtReportName"].value = reportName;
}

I haven't tested the code above, so it probably needs some tweaking, but
this should give you an idea of what you need to do.

Regards,

Mun
 
Back
Top