title: Redirect From Login Page In Windows Form
body: <p>Ok Guys i Have 2 pages one Login and One Page is the Form Registration I want that the Login Page should come first and only after Login succesfull it redirects to the Registration page. It was easy for me in the Web Approach using Session variables but when i am trying to do it in the Windows Application The Registration page is coming first and only after logout from Registration page then My whole thing is working correct. But i want that on startup itself the Login page should come.</p>
  
  <p>This is the Code i wrote</p>
  
  <pre><code>//----THIS IS IN THE REGISTRATION PAGE
          public static string Admin="";
  protected override void OnVisibleChanged(EventArgs e)
      {
          base.OnVisibleChanged(e);
          this.Visible = false;
      }
      private void Form1_Load(object sender, EventArgs e)
      {
          //--------------------------WORKS WHEN FORM IS LOADED
          //this.Visible=false;
          if (Admin == "")
          {
              this.Hide();
              LoginObject.Show();
              //this.Close();
          }
          else
          {
              Admin = LoginObject.AdminId();
              this.Show();
              FormLoaded();
          }
  //--------------THIS IS IN LOGIN PAGE
  
  public static string Admin="";
  private void ButtonLogIn_Click(object sender, EventArgs e)
      {
          string AdminUserName = TextUserName.Text;
          string AdminPassword = TextPassword.Text;
  
          //--------------------------------VERIFY ADMIN 
  
          GetSetAdmin.AdminUserName = AdminUserName;
          GetSetAdmin.AdminPassword = AdminPassword;
          BusinessClassAdminLogin BusniessObject = new BusinessClassAdminLogin();
          string AdminAuthorised = BusniessObject.ValidateAdmin(GetSetAdmin);
          if (!AdminAuthorised.Contains("-1"))
          {
              //Session["Admin"] = AdminAuthorised;
              //Response.Redirect("EmpRegistration.aspx");
              Admin = AdminAuthorised;
              EmpRegistration EmpRegObject = new EmpRegistration();
              this.Hide();
              EmpRegObject.Show();
          }
          else
          {
              MessageBox.Show("UserName or Passowrd Dont Match");
          }
      }
  //---------------------MAIN FUNCTIOn 
     static void Main()
      {
          Application.EnableVisualStyles();
          Application.SetCompatibleTextRenderingDefault(false);
          //Application.Run(new EmpRegistration());
          Application.Run(new Login());
      }
  </code></pre>