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
Visual Basic.NET.NET Programming

Avatar of undefined
Last Comment
mgmhicks
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?
Avatar of YZlat
YZlat
Flag of United States of America image

<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()
Avatar of YZlat
YZlat
Flag of United States of America image

not asp.net? I thought you said a "webform"...
Avatar of YZlat
YZlat
Flag of United States of America image

also how do you open a new window? button click?
Avatar of mgmhicks
mgmhicks

ASKER

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.




Avatar of mgmhicks
mgmhicks

ASKER

this is code to open window

Server.Transfer("crReports.aspx?PropertyID=" + ddProperties.SelectedItem.Value + "&BldID=" + mNewBld + "&AptNo=" + mNewApt + "&ReportID=" + "FC")
Avatar of YZlat
YZlat
Flag of United States of America image

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of mgmhicks
mgmhicks

ASKER

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.
Avatar of mgmhicks
mgmhicks

ASKER

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.

.NET Programming
.NET Programming

The .NET Framework is not specific to any one programming language; rather, it includes a library of functions that allows developers to rapidly build applications. Several supported languages include C#, VB.NET, C++ or ASP.NET.

137K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo