Link to home
Start Free TrialLog in
Avatar of mgmhicks
mgmhicks

asked on

How to close a web form

I have a web form that calls another webform to handle the printing of reports.  When the reports are finished I want to automatically close the web form.  Which should then put me back to the original form that called the print form.  Not sure code to get this done.  The windows just wants to remain open
Avatar of YZlat
YZlat
Flag of United States of America image

use javascript to do that
Avatar of mgmhicks
mgmhicks

ASKER

I am doing this with vb.net.  Could you give me a example?
<script language="JavaScript">

function open_a_window_please(){
window.open("childpage.htm");}

</script>

this code will open a child window and create a handle for it. The handle you could use later to close the chils window from the main page:

<script language="JavaScript">

function open_a_window(){
child_win = window.open("myprintpage.aspx");
}

</script>

code to close child window:

child_win.close()


to close the child window from itself, use the following javascript:

self.close()
not asp.net? I thought you said a "webform"...
also how do you open a new window? button click?
and this is the code I put on the calling page?  what about code to close, is that on the calling page or the printreport.aspx page?  I never really have had to add manually java script to my pages.




this is code to open window

Server.Transfer("crReports.aspx?PropertyID=" + ddProperties.SelectedItem.Value + "&BldID=" + mNewBld + "&AptNo=" + mNewApt + "&ReportID=" + "FC")
do you want to close the reports page from itself? if so, just run javascript selft.close() when it's done
ASKER CERTIFIED SOLUTION
Avatar of YZlat
YZlat
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
where do I put that code on the page.  Is it on the html side or the vb scripts side or what.  I want the print window to come up, send all print jobs to printer then when finished close and expose the previous web form.
ok, I think I'm getting somewhere.  When it closes it comes back and says "The windows is trying to close"  then I have to press ok to close it.  Can we make this do it automatically.  Where can I go for java scripts like the couple you should me.