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:
- <script type="text/javascript">
-
-
function helloWorld()
-
{
-
alert('hello');
-
}
-
-
</script>
-
<asp:Button runat="server" id="testbutton" text="Hello World!" OnClientClick="helloWorld();return false;" />
Hope that's some help.