473,386 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Login Screen

What is the best way do a login screen? I have the Main() method in my
login screen. After iit checks the userid and password the OK button
loads the main application form but the next line is frmLogon.Close()
which closes the whole application! If I hide it, the app does not
close completely. Thanks.

Nov 16 '05 #1
6 22774
Hi,

I guess you have at least 2 forms (login form and form for the application
itself). You can show the login from when your application is starting -
then check for username and pass and close both forms or just close the
login from.

--
Regards,
Peter Jausovec
(http://blog.jausovec.net)
"Marty" <ma********@absu.accenture.com> je napisal v sporocilo
news:11**********************@g14g2000cwa.googlegr oups.com ...
What is the best way do a login screen? I have the Main() method in my
login screen. After iit checks the userid and password the OK button
loads the main application form but the next line is frmLogon.Close()
which closes the whole application! If I hide it, the app does not
close completely. Thanks.

Nov 16 '05 #2
2 forms -

Main form and login form.
LoginForm shown as Modal Dialog Window as a child of MainForm.

- Sahil Malik
http://codebetter.com/blogs/sahil.malik/

"Marty" <ma********@absu.accenture.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
What is the best way do a login screen? I have the Main() method in my
login screen. After iit checks the userid and password the OK button
loads the main application form but the next line is frmLogon.Close()
which closes the whole application! If I hide it, the app does not
close completely. Thanks.

Nov 16 '05 #3
If I close the login form the whole application closes even if I load
the app form first. I can get around this by using frmApp.ShowDialog
so frmLogin.Close() dosen't happen until frmApp is closed but I
shouldn't have too.

Nov 16 '05 #4
LoginForm (e.g. 2 textboxes, 1 button):

private void button1_Click (...)
{
// check for valid username and password
if (textBox1.Text == "someusername" .... )
{
this.DialogResult = DialogResult.OK
}
}

MainForm:

private void Form_Load (...)
{
LoginFrm frm = new LoginFrm ();
if (frm.ShowDialog (this) == DialogResult.OK)
{
// username and pass are OK
return;
}
else this.Close (); // close the form
}

Hope this helps
--
Regards,
Peter Jausovec
(http://blog.jausovec.net)
"Marty" <ma********@absu.accenture.com> je napisal v sporocilo
news:11**********************@f14g2000cwb.googlegr oups.com ...
If I close the login form the whole application closes even if I load
the app form first. I can get around this by using frmApp.ShowDialog
so frmLogin.Close() dosen't happen until frmApp is closed but I
shouldn't have too.

Nov 16 '05 #5
Peter,
Thanks for the code. It solved my problem.
Marty

Nov 16 '05 #6
Best way...:

static void Main()
{
LoginDlg ld = new LoginDlg();
if (ld.ShowDialog() == DialogResult.Ok)
Application.Run(new Form1());
}

Nov 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Chip | last post by:
I am trying to get sessions to work on a log in screen to give certain users access to certain pages/directories. The problem is that when the login button is pushed (or the enter key pressed) the...
3
by: Steve | last post by:
I am new to .Net and Visual Studio, I have a login form and my main application form. When I login I want to call the application form, and dispose of the login. I have tried doing something...
1
by: Mohan | last post by:
Hi all, I am having a problem implementing forms authentication for a web application. I have a login screen and any unathorized user is directed to the login screen. The problem is that the...
0
by: JIM.H. | last post by:
Hello, My connection string in config.web: <appSettings> <add key="connStr" value="workstation id=myServer;packet size=4096;user id=MyUser;data source=MYSERVER;persist security info=True;initial...
9
by: dana lees | last post by:
Hello, I am developing a C# asp.net application. I am using the authentication and authorization mechanism, which its timeout is set to 60 minutes. My application consists of 2 frames - a...
1
by: leovega | last post by:
Hello, My aplication starts with a simple login window (login_page.aspx). Once the login/password is validated I redirect to an html which contains 3 frames. (mywebsite.html) The web site I...
3
by: bala | last post by:
Hi Gurus The scenario A MS Access frontend application with Oracle Backend (Linked Tables). The Database UserID and password is not stored and each user has a unique UserID and password. There...
10
by: =?Utf-8?B?UmljaGFyZCBCeXNvdXRo?= | last post by:
Hi In my app I have a SplashScreen, a login form and a main form. On launching the app, I'd like to show the SplashScreen while reading config files and attempting a database connection. I show...
4
by: Gaz | last post by:
I am having a bit of a problem getting my application to work properly. RIght here is my problem... WHen my C# windows app loads up the start form, i create a new thread and show the splash...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.