Can't close my web form

Hi:

I have a web ASP.Net form (C#.net) where I have an Exit button. Behind the button I have the code:

protected void btnExit_Click(object sender, EventArgs e)

{

Response.Write("<script language='javascript'> { self.close() }</script>");

}

It's working ok and exits from my web form. In the form I display a chart. If I click on Print Preview from File Menu, then print the chart and close the print preview window, after that my Exit code does not work. It again and again runs the same page and displays the chart. I can't exit from my web form.

Pls help..... I can't find the solution.

Thanks in advance

Maksuda


maks...
0
maksuda
2/10/2009 5:52:14 PM
asp.net.web-forms 93655 articles. 6 followers. Follow

9 Replies
532 Views

Similar Articles

[PageSpeed] 59

Try to use window.close()

<asp:Button ID="Button1" runat="server" Text="Close" OnClientClick="window.close();" />


Regards,Vinz

"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
0
vinz
2/10/2009 6:30:54 PM

Thank you vinz for your reply.

I tried using

<asp:Button ID="Button1" runat="server" Text="Close" OnClientClick="window.close();" /> 
still getting the same result. Doesn't work.

Maksuda...


maks...
0
maksuda
2/10/2009 7:28:41 PM

Please any help regarding Form close button is highly appriciated.

 Maksuda...


maks...
0
maksuda
2/11/2009 5:25:27 PM

Since you are using javascript i would suggest use html button control and call this script on click event of it.

Let's try this and let me know if you still getting the same behavior.

 

Thanks

 


Thanks & Regards,
Izhar Ul Islam Khan
Microsoft Certified Technology Specialist
0
izharulislam
2/11/2009 5:55:10 PM

Did you ask somthing like below:

<input id="Button2" type="button" value="button" onclick="window.close();"/><br/>

Still not working

getting upset..............Couldn't find the way how could I make it working......................

 

Maksuda...


 

maks...
0
maksuda
2/11/2009 6:12:19 PM

with a google search I figured you're using firefox to test. Firefox doesn't let you close a window you didn't open I guess. so change the JS code to this:

javascript:window.open('','_parent','');window.close(); this will work around the issue.
 

 

0
Omego2K
2/11/2009 6:36:20 PM

Thanks Omego2K for the reply. I'm using IE7.

I tried with all possible codes to close the web form. If I run the form and close it; it's ok and my form closes. But if I go to the print preview after that close command does not work. Clicking on close but runs the form again and again. I couldn't find out the reason and upset about it.

Maksuda...

 


maks...
0
maksuda
2/11/2009 7:09:52 PM

maksuda:
Clicking on close but runs the form again and again

 

<base target="_self">

0
Tomorrow
2/16/2009 2:42:44 AM

Hi Tomorrow: Would you please explain a little bit about <base target="_self">

where i have to use it..........

Maksuda...


maks...
0
maksuda
2/17/2009 3:19:56 PM
Reply:

Similar Artilces:

For interrupting.web form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form
Web Form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form ! Because of my pool English, if you can't see , I will explain more ! ThanksGambler is the real life I guess you mean when form grows it also grow parent div element. This is normal. If you want div to stay fixed size and rather clip the form and maybe show a scrollbar, look at overflow property in CSS.Thanks------------------------------------------------------------This posting is provided "AS IS" with no warranties, and confers no ...

can someone one give me difference between web form and mobile web form and which or where or when i'm using the forms?
thanks Marc Hi Marc, Based on my understanding, you want to know the differences between the ASP.NET web application and ASP.NET mobile web application. If I have misunderstood you, please feel free to let me know. The ASP.NET forms are used to develop the ASP.NET pages for desktop browsers and The ASP.NET mobile forms are used to develop the ASP.NET pages for mobile device browsers. When we create the ASP.NET mobile web forms pages, we can use nearly all the features of ASP.NET. But there are a couple of compatibility issues: Error Handling and Reporting. Tracing. Using Redi...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

Can my web page with a form submit to other web pages forms?
I was wondering if I created an aspx page that had a form on it that I could use the submit button to submit this form's contents to other web pages forms(servers accepting those form's data). I am thinking this would be a great way to update data on particular web pages without having to actually visit those similar web pages. Any ideas, examples would be much appreciated. Thanks in advance.  Yes you can.  It's called Cross Page Posting: http://msdn2.microsoft.com/en-us/library/ms178139.aspxAlso: http://msdn2.microsoft.com/en-us/library/ms178140.aspx might ...

It's all very fuzzy now...can make web request(?) but definately can't get web response from web service
Alas...trying to get a web service response from a web service that is part of the web site in Visual Studio.Net 3.5 appears to be impossible.  Infact, I've been ALL over the internet over the past couple of days looking at all types of fragmentory examples in all types of Microsoft languages to no avail. =========QUESTION:=========1.  How do I call a web service (the function to call is "WebService_BulkData") so that my aspx page will send it a SOAP request and print out the web service response data to the page?  The aspx page AND the web service are part of t...

How to Make Web Forms from other Web Forms
In putting together an ASP.NET application for a biz application, we have come to the point where there are three different types of basic forms which have, for the most part, been perfected. Now its is a matter of cloning those forms for various uses and modifying or adding code to suit the particular need. Copy and paste works OK, but there is a lot of changing of certain words, etc. Is there a way in ASP.NET to take these basic forms, turn them into classes or templates, create forms from them, then add or overwrite code? ? (Anybody who is a Vis Fox Pro programmer would know imme...

Web forms and mobile web forms
Hey everyone, I am looking to develope a web site that depending on the device connecting to it, it will display a certain page. In this case im looking to create a web and wap version of the same project. I have the Web forms version finished using ASP.NET and C# and I am wondering how to create the mobile web form and incorporate it in the project. In the project folder, can I just add a mobile web??? But what about displaying device specific pages?? Cheers -Dudach Yes, you can add mobile web forms and controls to your Web Application project. No problem. For device/br...

Can't add web form
hi, When I try add web form in my project it doesn't add and gives me an error. here is an error details. ==================================================== Error Details An unhandled exception has been caught by VSW exception filter. Error Signature AppName: devenv.exe AppVer: 7.1.0.3077.0 ModName: urlmon.dll ModVer: 6.0.2800.1400 Offset: 00004a8f ===================================================== can anyone help me what's wrong? thanks. ...

Can't add web form
hi, I'm posting this question 2nd time. When I try to add web form in my project it gives me an error and doesn't show in project explorer. But when i check in project folder you can see the same file. here is an error details. ==================================================== Error Details An unhandled exception has been caught by VSW exception filter. Error Signature AppName: devenv.exe AppVer: 7.1.0.3077.0 ModName: urlmon.dll ModVer: 6.0.2800.1400 Offset: 00004a8f ===================================================== can anyone help me wha...

Can "Add Web Reference" if web service deployed to new web site, Can't add ref if deployed to Virt Server under Default web site (Sharepoint)
I have created a web service wich I can deploy successfully to a new IIS Web, but of course I have to set the port to something other than 80 (and I'd rather just use a virtual server under the Default web). If I try to deploy my web service under the Default Web as a new virtual server, and then try to "Add a web Reference" to the service, it fails with a 404: not found error. Notes: WServer 2003 My IIS server is running Sharepoint Portal Server (SPPS)sp2.  VS2005 Any ideas? /Bob C in GRR In Sharepoint Portal Admin I had to add a Path Exclusion.  Took me a whi...

How to fire events in other web form from other web form ?
Suppose that I have A and B web form. I want to trigger B web form's Page_Load event from A web form. How can I do that ? Thanks in advanced WilbertWilbert Bujn Create a public method in B that call the load method : public void Load(object sender, System.EventArgs e) { Page_Load(sender, e) ; } In the page_load of A, instanciate a B object and then call the function B myB = new B() ; myB.Load() ; Quicky Thank you quicky, it works fine. WilbertWilbert Bujn...

Web Form vs. Web Content Form
If you don't mind, I would like to know what is the difference between those two items, when I go to add a new item I see both of those and I don't know what the difference is.  A content form is for use with a masterpage. A web form is a standalone web page. If you select web content form, you will then have to specify a masterpage for it. and what is a master page used for?  Hi, a master page is used to give a constant look and theme to a site, without having to duplicate code. So basically you can put your header, menu, nav and footer on a master page. Then a...

calling a web form from another web form
I would like to know what is the best way to open a web form from another web form. I would like to call it from a button control. Thanks Well, if I've grasped your question right, there are many methods to do that: 1)Response.Redirect > To navigate to another page from code and is equal to clicking a hyperlink. I suggest this as I think it's closer to your question. 2)Server.Transfer > This ends the current web form and begins a new web form. It's usable when you want to pass some variables i.e (Label1.Text) to the next immediate page. It's not safe though and not used to send p...

Include web form inside web form
I tried to include an aspx file in a asp.net web form. However, all the web controls (textbox, button) in the included page are not displayed when called. <Form id="Form1" method="post" runat="server"> <%   Response.writeFile("subPage.aspx"); %> <asp:button id="btnPrev" runat="server" text="Previous"></asp:button> </Form> There are some <asp:textbox> controls in the subPage.aspx file, the file itself works fine, but when it is included in the main page, all the controls are not displayed. Please assist. Thanks   u should u...

Web resources about - Can't close my web form - asp.net.web-forms

Resources last updated: 11/30/2015 8:30:36 PM