Hi Readers,
If you have tried using javascript window.close() method in IE7, you will notice that it is always prompting “The Webpage you are viewing is trying to close the window. Do you want to close this window?”.
To let this prompt not to appear, just do the codes below.
script language="javascript"
function CloseWindow()
{
window.open(”,’_self’,”);
window.close();
}
/script
Or if you want to close the Parent window without prompting, just use:
window.opener.open(”,’_self’,”);
window.opener.close();
The code in bold is used to open a window which lets the browser thinks that the current window is opened using javascript window.open(), so when the close() method is executed it will close it without the message being prompted.
Best Regards,
Shaper Jabneel
Thursday, October 16, 2008
Allowing Only One Instance of an Application in C#.Net
Hi Readers,
Standard Windows Form application can be launched multiple times and each instance used completely independently of the others। However, sometimes it is important to restrict the user in launching multiple instance of a program।
See the code snippet below in how to restrict lunching of multiple instance of an application.
Required Namespace:
System.Diagnostics
C# Code:
static void Main()
{
// Detect existing instances
string processName = Process।GetCurrentProcess().ProcessName;
Process[] instances = Process.GetProcessesByName(processName);
if (instances.Length > 1)
{
MessageBox.Show(”This application is already running.”);
return;
}
// End of detection
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
Hope this would help you folks. Thanks.
Best Regards,
Shaper Jabneel
Standard Windows Form application can be launched multiple times and each instance used completely independently of the others। However, sometimes it is important to restrict the user in launching multiple instance of a program।
See the code snippet below in how to restrict lunching of multiple instance of an application.
Required Namespace:
System.Diagnostics
C# Code:
static void Main()
{
// Detect existing instances
string processName = Process।GetCurrentProcess().ProcessName;
Process[] instances = Process.GetProcessesByName(processName);
if (instances.Length > 1)
{
MessageBox.Show(”This application is already running.”);
return;
}
// End of detection
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
Hope this would help you folks. Thanks.
Best Regards,
Shaper Jabneel
Subscribe to:
Posts (Atom)