Interaction between 2 webforms

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.
 
M

Munsifali Rashid

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top