We help IT Professionals succeed at work.

How to close a web form

623 Views
Last Modified: 2012-05-05
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
Comment
Watch Question

CERTIFIED EXPERT

Commented:
use javascript to do that

Author

Commented:
I am doing this with vb.net.  Could you give me a example?
CERTIFIED EXPERT

Commented:
<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()
CERTIFIED EXPERT

Commented:
not asp.net? I thought you said a "webform"...
CERTIFIED EXPERT

Commented:
also how do you open a new window? button click?

Author

Commented:
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.




Author

Commented:
this is code to open window

Server.Transfer("crReports.aspx?PropertyID=" + ddProperties.SelectedItem.Value + "&BldID=" + mNewBld + "&AptNo=" + mNewApt + "&ReportID=" + "FC")
CERTIFIED EXPERT

Commented:
do you want to close the reports page from itself? if so, just run javascript selft.close() when it's done
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
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.

Author

Commented:
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.

Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.