hi,

i have created a login form for my project and coded it, but when the username and the passsword is correct i have added the below code

Qustion 1

if (u.accessGranted(txtUsername.Text, txtPassword.Text))
            {
                ClearTextBoxes();
                new frmMainMenu().Show(); // main form after the login
                this.Close();//login form
       
            }

but when the login in successful the application closes without opening the other form,
why is this happening???

Question 2
and also when a login is uncusseful i do i direct the cursor to do the the username textbox???

appriciate if someone can give me an answer,

thanxxx

If the form - that you are trying to close - is the default form. Then closing it will also close the application. You should hide it instead of closing it. Just change this.Close(); to this.Hide(); You can use this to focus the username textbox: txtUsername.Focus(); Final code with all the above changes:

if (u.accessGranted(txtUsername.Text, txtPassword.Text))
            {
                ClearTextBoxes();
                new frmMainMenu().Show(); // main form after the login
                [B]this.Hide();[/B]  
            }
            else
            {
                 txtUsername.Focus();
            }

Thanks

Edited 6 Years Ago by farooqaaa: n/a

1.first you need to use response.redirect("the pageu required.aspx") in place of new frmMainMenu().Show();
2.for second prob u need to use textbox_textchanged event

oh i think u should use mdi parent form as default start up form and
put your login form as child form of mdi parent form . It is very easy to close and open child form ......

This question has already been answered. Start a new discussion instead.