473,396 Members | 2,037 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Closing One WebForm from another Webform

VijaySofist
107 100+
Hi All!

I want to close one web form thro another web form coding(i.e thro server side coding). Can Anybody help me for this.

I am using Asp.Net 2.0 with VB Coding in Microsoft XP Machine.

Thanks in Advance

With Regards
Vijay. R
Mar 26 '08 #1
5 1225
Hi All!

I want to close one web form thro another web form coding(i.e thro server side coding). Can Anybody help me for this.

I am using Asp.Net 2.0 with VB Coding in Microsoft XP Machine.

Thanks in Advance

With Regards
Vijay. R
You can't really do it server-side, since the client is responsible for managing which windows are open and which are closed - and to ackle client-side operations (like closing one browser window and opening another one) you'd need to use JavaScript.

Because web browsing is event based (E.g. the server sends the client browser a page, the client browser does something with it - e.g. fill out a few input boxes, and then submits it - the server recieves the response, then processes it) you will need to make the client raise an event, so the server knows they want to receive the next webform.

A couple of solutions might be:

A) Stream JavaScript out with the first webform that sets a timer (see setTimeout() method), and after a certain time submits the page, allowing the server to stream the next page.

B) If the second webform is in another browser window, investigate the Javascript window.close() method (w3schools.com is good for all this).

You could stream the necessary JavaScript to the client in a seperate .js file as a webresource (do a google for asp webresource), or you could embed it in the webforms declarative markup:

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3.  function helloWorld()
  4.  {
  5.   alert('hello');
  6.  
  7. </script>
  8. <asp:Button runat="server" id="testbutton" text="Hello World!" OnClientClick="helloWorld();return false;" />
Hope that's some help.
Mar 26 '08 #2
kunal pawar
297 100+
Hi,
using server code u can not close client browser but using javascript u can close client browse.

But before that u have to set parent of browser so it will not ask for close browser message
use window.close() method to close browser
Mar 26 '08 #3
VijaySofist
107 100+
Hi All!

Thanks for the Response. I can't use the javascript because when using javascript I can close only the current window. I want to make a function in ASP.Net Server side code that will end the webform whereever I Call.

Thanks in Advance
Vijay. R
Mar 27 '08 #4
deric
92
Hi..
Are you trying to close the webpage that opened the new webpage?
If so, you can do this on client side with javascript using its "opener" object.

I made a simple simulation:
Expand|Select|Wrap|Line Numbers
  1. test1.html:
  2. <html>
  3. ...
  4. <a href="#" onclick="javascript:window.open('test2.html');">open</a>
  5. ...
  6. </html>
  7.  
  8.  
  9. test2.html:
  10. <html>
  11. ..
  12. <script language="javascript">
  13. opener.close();
  14. </script>
  15. ...
  16. </html>
  17.  
Mar 27 '08 #5
VijaySofist
107 100+
Hi All!

I found the code to close one webform from the other webform thro the server side coding.

This is the Code.
Expand|Select|Wrap|Line Numbers
  1. Me.ClientScript.RegisterClientScriptBlock(Me.GetType, "my_window", "<SCRIPT language=JavaScript1.2>window.close();</SCRIPT>")
  2.  
We can call this any where around the webform in the server Side coding to cose the webform.

Thanks for all who responded me.

With Regards
Vijay. R
Apr 1 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Andrew | last post by:
Hi, Until now, I have used a single webform for my web app, and everything's been OK. Now, I've decided to create a main menu webform. So, I've got two webforms. Using Visual Studio .NET (with...
6
by: Phillip N Rounds | last post by:
I have a webform, from which I have to submit info to another site. Their instructions are to have a html form, with the following as the submit: <form method="post"...
1
by: Chirag Malvi | last post by:
hello all, I am developing the web application using ASP.net and VS.2003 IDE. here is the situation which i want to implement. 1) User is browsing some webform. I want to trap this event....
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
3
by: Dean Slindee | last post by:
Would like to call the TabShow function on WebForm InOutHost from another WebForm in same project, but cannot figure out how to get a reference. Can this be done? In this statement: Call...
2
by: lakshmikandhan | last post by:
Hi All, Can anyone tell me how to handle a event while we are closing a webform in asp.net??? I have to perform some server side action while we are closing a webform.So plz give me some idea...
7
by: Max | last post by:
Please somebody can shed a light... How can I have a variable visible and modifiable, inside one and only webform? I mean , I d like to see that variable from all the Sub of that webform code,...
2
by: Luqman | last post by:
How can I open another WebForm in ASP.Net / VS 2005 without closing the Current Webform. I tried using Server.Transfer("Form2.Aspx",True) on Button_Click of Form1 but it close the current web...
5
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have start web form and when the user clicks a button (server.transfer) they are directed to the second webform. I was wondering if there is a way to create an instance of the first webform...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.