#24364 Author: Rajesh Reddy Member Level: Gold Member Rank: 0 Date: 30/Jun/2005 Rating:  Points: 2 |
Hi Muthu! I don't think you can close the main form when the Child form is alive. Try it. If you are not done, follow this.
Hide the Form1 while activating the Form2. When you close the Form2, You must explicitly close the Form1.
I don't know how feasible this solution be but it serves your problem. The overheads in this approach are 1. You have to maintain the reference of the Form1 in some global area (like static variable) 2. Though Form1 is hidden, it will be in memory till you close Form2.
|
#24369 Author: Raghavendra Rao Member Level: Silver Member Rank: 0 Date: 30/Jun/2005 Rating:  Points: 2 |
Try using window parent/child relation using a script.
Here it goes
Call a window close function on click of login button as follows.
private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here LoginButton1.Attributes.Add("OnClick","openWindow('child.aspx?login=true');"); }
and write the following script code in the login.aspx
<script language="javascript"> function openWindow(url) { window.open(url); } </script>
in the child.aspx i.e. the page where you want to redirect the user after login, write a small script on body load as follows.
<html> <head> <title>Successfully Logged in!!!</title> <script language="javascript"> function MaximiseWindow() { x = screen.width ; y = screen.height window.resizeTo(x,y); window.moveTo(0,0); window.opener.close(); } </script> </head> <body MS_POSITIONING="GridLayout" onload="javascript:MaximiseWindow();"> <form id="Form1" method="post" runat="server"> You are successfully loogged in....
</form> </body> </html>
But you are likely to get a warning message in IE , to check whether you want to close the window. If you want to avoid this , you can open the login form also in a window.
Hope this helps you..
Cheers Rags
|
#24372 Author: Zabiullah Member Level: Silver Member Rank: 0 Date: 30/Jun/2005 Rating:  Points: 2 |
Hi!
Use Thread to open another Form!!! Check this sample code...
private void btnLogin_Click(object sender, System.EventArgs e) { this.Close(); Thread th = new Thread(new ThreadStart(myForm)); th.Start(); }
private void myForm() { Form2 f = new Form2(); f.ShowDialog(); }
Regards, Zabi.
|
#27097 Author: Senthil Member Level: Bronze Member Rank: 0 Date: 03/Aug/2005 Rating:  Points: 2 |
Hi Muthu Try This.... 1) create a Object for Form 2 2) Activate Form2 3) Hide the Parent Form For an Example Here Form 1 is Parent Page (Login Page ) and Form 2 is Next Page.
private void button1_Click(object sender, System.EventArgs e) { Form f2=new Form2(); f2.Show(); // This Activates Child Form this.Hide(); // This Hides Parent Form (Login Form) } Please forward ur Feedback..............
|
#29295 Author: Arthy Member Level: Silver Member Rank: 0 Date: 01/Sep/2005 Rating:  Points: 2 |
hi
try using
window.opener.close(); in the child form
regards Arthy
|
#50868 Author: Munawar Member Level: Bronze Member Rank: 0 Date: 02/May/2006 Rating:  Points: 2 |
[STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false);
Loginfrm = new Login(); frm.ShowDialog(); //make boolean property IsCloseAll and default it to true //So that if user hit cross he can go out //and dont forget it to set it false at the event where user want // to close login form and come to MainForm if (frm.IsCloseAll != true) { Application.Run(new MainForm()); } }
|
#142261 Author: sunil mishra Member Level: Silver Member Rank: 0 Date: 06/Aug/2007 Rating:  Points: 2 |
Hey use this for c# ...................................................................................................................................................................... ....................................................................................................................................................................... ........................................................................................................................................................................
[code in programe.cs file]
[STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Login()); }
[/code in programe.cs file]
[code in Login.cs file]
private void login_click(object sender, EventArgs e) { this.close(); //"this" is used for login form which would be closed
// include ref : system.Thread;
Thread th = new Thread (new ThreadStart(myform)); th.start;
}
Private void myform() { frmMDI f = new frmMDI(); // frmMDI is the next form which would be open f.showdialog(); } [/code in Login.cs file]
|
#178053 Author: Charles Irwin Kumar Member Level: Silver Member Rank: 0 Date: 10/Jan/2008 Rating:  Points: 2 |
For Each ChildForm As Form In Me.MdiChildren ChildForm.Close() Next
|