473,385 Members | 1,357 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,385 software developers and data experts.

Create an exit button in C#

17
Hi,

Can someone please help me with an exit button in C#. I have an exit button that does not work.
Jun 25 '09 #1
8 16305
cloud255
427 Expert 256MB
By exit button do you mean a button to close the application?
You need to be a bit more specific in order for us to understand the problem you are facing.

If you do want a button to close the form, you can simply call the Dispose() method of the form.
Jun 25 '09 #2
Curtis Rutland
3,256 Expert 2GB
You are going to have to be FAR more specific than that. First, post the section of your code that isn't working, explain exactly what it is supposed to do, explain what it actually is doing, and post the error text, if any. Also let us know if this is a Windows Forms app or an ASP.NET app.

Then we might be able to help you.
Jun 25 '09 #3
nbiswas
149 100+
Assuming windows application

Expand|Select|Wrap|Line Numbers
  1.  this.Close();
OR
Expand|Select|Wrap|Line Numbers
  1. this.Dispose();
Assuming Web Application,

It is always recommended to handle using client side scripting(e.g. Javascript)

On the button's client side click event call a function say "CloseMe()"

Expand|Select|Wrap|Line Numbers
  1. <script language="javascript" type="text/javascript">
  2.     function CloseMe()
  3.     {
  4.         window.close();
  5.  
  6.     }
  7.     </script>
But as the others mentioned, you should be more specific while asking your question.
Jun 26 '09 #4
zizi2
17
Thanks it worked !
Jun 26 '09 #5
cloud255
427 Expert 256MB
You're welcome, glad we could help, but you please need to understand that this is a place where people from all over the world communicate via a written medium.

I know that its not always easy to express oneself, but could you please tell us the following so that this thread may still be of future use:

1. Was this a web based or form application?
2. Did you simply want to hide a form or remove it from memory?
3. Which solution worked for you?

By doing this someone else who is facing a similar problem may find their solution in this thread.
Jun 26 '09 #6
zizi2
17
Hi,

it was a a Web application that needed to be removed from memory and I used

<script language="javascript" type="text/javascript">
function CloseMe()
{
window.close();

}
</script>
Jun 26 '09 #7
cloud255
427 Expert 256MB
Hi,

I'm not really involved in web programming, so i might be totally wrong here, but using that code on the client side will close the client side application, the server side code will still be in memory.

If you have a dedicated application on a web server, then this is totally correct, but if you wish that the server side memory also be freed, you will have to write C# code dispose of the application. Just something to keep in mind.

P.S. thanks for the extra details regarding your problem.
Jun 26 '09 #8
Curtis Rutland
3,256 Expert 2GB
For the record, I've never written anything to unload the session from the server's memory. Sessions expire on their own. Also, the app is constantly running, otherwise it wouldn't be available from the web. So simply closing the page is a valid solution.

Make sure that you test that code in multiple browsers, not all of them implement JS in the same way.
Jun 26 '09 #9

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

Similar topics

1
by: s-galit | last post by:
im using "Error Provider" in my form , the problem is that when im trying to exit the program by the exit button on the title bar im getting disturbed by the error provider so i cant exit the...
4
by: Tim Wallace | last post by:
I have an ascx file in which I want to sometimes create an asp:button control based on a given value. Nothing I've tried has worked. How can I accomplish this task? Tim
4
by: Andre | last post by:
Hi, I have an application that display users invoice. On every page i have an "Exit button". Is there a way, if the user click on "Exit" (to logoff from the system), and after on Back in is...
4
by: Adam - Regus | last post by:
I'm trying to create a button that prints 2 copies of a form. Using the wizard, I created a button that prints one automatically, using the following code: End Sub Private Sub...
2
by: jsimons | last post by:
If the user accidentally clicks the X close button I'm using the following code in the form unload event to stop them from accidentally quitting Access. Private Sub Form_Unload(Cancel As...
4
by: gls007 | last post by:
I am building a database and trying to make it simple for others to use. I am attempting two things and am not sure how to complete them. I would like to add a search for single record choice and an...
1
by: Henry Lee | last post by:
Hi, I am using Asp 2.0 environemnt to develop our company Intranet. This should be a easy task for some of you but I just have no clue to make a exit button on the web page for user to click and...
3
by: oozy | last post by:
Hi, I'm currently using Page.Form.DefaultButton = ChangePassword1.FindControl("xx").UniqueID to set my DefaultButtons in a form that has multiple wizards(each in it's own panel). I can...
2
by: Vinnie123 | last post by:
In my application, sometimes users accidentally click the "exit" button in the far right corner of the browser window and lose all of their unsaved work. Is there a way to prevent the window from...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.