473,756 Members | 2,378 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

oForm.Close() vs this.Close() in a modal dialog.

oForm.Close() vs this.Close() in a modal dialog.

oFrom.Close() calls Form.Dispose() but this.Close() ,say in the click
event of the Form, does not.

I can think of the reason for this but is this documented and if so can
someone give me the reference. And is this true for .net 1 and 2.

Thanks

Dan

Nov 12 '06 #1
1 3868
Hi Dan,
when a form is closed then Dispose is called as you mentioned so that all
of the resources associated with the form are cleaned up, from the msdn
documentation:

"When a form is closed, all resources created within the object are closed
and the form is disposed."

When you are in a modal dialog typically after the form is closed you want
to retrieve values from the form, so you do not want the form to be Disposed,
which is why the dispose is not called when called internally. You need to
remember to call Dispose after closig the modal form, or put it inside a
using statment.

This is the same for both 1.1 and 2.0. As for a specific document stating
the above try: http://msdn2.microsoft.com/en-us/library/c7ykbedk.aspx

which states:

"When a form is displayed as a modal dialog box, clicking the Close button
(the button with an X at the upper-right corner of the form) causes the form
to be hidden and the DialogResult property to be set to DialogResult.Ca ncel.
Unlike modeless forms, the Close method is not called by the .NET Framework
when the user clicks the close form button of a dialog box or sets the value
of the DialogResult property. Instead the form is hidden and can be shown
again without creating a new instance of the dialog box. Because a form
displayed as a dialog box is not closed, you must call the Dispose method of
the form when the form is no longer needed by your application."
Mark.
--
http://www.markdawson.org
"da********@gma il.com" wrote:
oForm.Close() vs this.Close() in a modal dialog.

oFrom.Close() calls Form.Dispose() but this.Close() ,say in the click
event of the Form, does not.

I can think of the reason for this but is this documented and if so can
someone give me the reference. And is this true for .net 1 and 2.

Thanks

Dan

Nov 12 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
16144
by: Simon Storr | last post by:
Is it possible to make the parent window refresh when a modal dialog is closed? I know I can use window.opener.location.reload(true); for a 'normal' window, but this doesn't work for showModalDialog. It is modal as far as the client is concerned but not the server... In my app I have a datagrid on the main aspx page, I pop up a modal dialog to edit a record. On closing the modal dialog I'd like to refresh the
8
2224
by: william | last post by:
Hi All, I have a question about closing a dialog box. The thing is: I have two ASP.NET pages. From one page, I open another page as window.showModalDialog. THere is a button on the second page. On the click event of the button on second page, I put code "Response.Write("<script language='javascript'> { self.close();}</script>")" or "Response.Write("<script language='javascript'> { window.close();}</script>")". But it doesn't work. WHen I...
2
3307
by: anil kumar via .NET 247 | last post by:
(Type your message here) hi, i am using save & cancel webform button my webpage to with somevalidations , when i am trying to save my content it is savedthat time i need a popup msg like ur 'data is saved' , and wheni am trying to click on cancel the page should terminate witheffecting of validations . and how to open a modal dialog page through vbscript -------------------------------- From: anil kumar ----------------------- Posted by...
4
5517
by: Hitesh | last post by:
Hi, I am opening an Modal dialog box using the window.Showmodaldialogbox(), and in that window i am having an aspx form with say one ASP.NET Button control. i am doing some operation on the click event of the button control on the server and finally closing the window by using the following statement at the end of the click event of the button: Response.Write("<script language='javascript'>window.close();</script>"); But instead of...
1
2803
by: Alex Brown | last post by:
I am writing a vb.net windows application and am using functionality in a com dll written in vb6. There is a modal dialog that pops up when I call a function in the dll that I want to automatically close. I am 90% sure that the dialog is generated by the vb6 msgbox funciton. I don't need to do anything except close the dialog - it just has an OK button. What is the easiest and best way to close the dialog automatically? Thanks!
22
130375
by: stephen | last post by:
I have created an order form that users javascript to create a new html document when the customers clicks the "print page" button. Once the new document has been created it then prints the document and closes it with the following code: <body onload="window.print(); window.close();"> This works correctly (or at least the way I expect it to work under MS Internet Explorer, but it cuases Netscape to "crash"
0
1019
by: **Developer** | last post by:
The following is from the docs. But what about if the form executes Me.Close. I experimented a little but can't be sure. Is the Close Method called? I'm not sure what is meant by the Close method, The Close and Closing events are called even if the X is clicked or Me.Close is called, I checked that.
2
3796
by: =?Utf-8?B?TGVuaTIwMDA=?= | last post by:
Hi, I would like to write a c# application. to detect if a modal dialog opens on another application, (e.g. notepad.exe save changes dialog when you click exit ) and auto cancel it. How do I detect the modal dialog opening? Thanks for your help Leni
2
1462
by: Thiago Macedo | last post by:
Hello everybody. I'm experiencing an strange problem with WinForms which someone, if possible, could help me to deal with. We have a windows application which serves as a menu, calling other forms in different class library, all called as Modal Dialog. In one of this forms, I have another call to a Modal. When this second modal is closed, automatically is closed the form who called it. I can't understand how this is happening. After the...
0
9431
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9255
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10014
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9689
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8688
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6514
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3780
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3326
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2647
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.