0

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

4
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by rsodarith
1

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 by farooqaaa: n/a

0

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

0

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.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.