Login dialog

A

Alejandro Casal

Hi there,

I'm writing a .net Windows application in C#. I have 2 forms: the MainForm
and the Login. The MainForm opens the Login as Dialog from the MainForm's
constructor, and Login asks for username/password. I get these data from the
MainForm and check using a Web service that they're ok. If username/password
are not ok, I want to close the whole application, but I don't know how
(this.Close() doesn't work). Can I close the app from the MainForm's
constructor? Should I call the Login dialog and web service somewhere else?

Thanks,

Alejandro.
 
H

Herfried K. Wagner [MVP]

Hello,

Alejandro Casal said:
I'm writing a .net Windows application in C#. I have 2
forms: the MainForm and the Login. The MainForm opens
the Login as Dialog from the MainForm's constructor, and
Login asks for username/password. I get these data from the
MainForm and check using a Web service that they're ok.
If username/password are not ok, I want to close the whole
application, but I don't know how (this.Close() doesn't work).
Can I close the app from the MainForm's constructor? Should
I call the Login dialog and web service somewhere else?

The only way preventing the class from being instantiated is to throw an
exception.
 
Y

Ying-Shen Yu[MSFT]

Hi Alejandro,
You may try implement it this way.
1. In Constructor of your MainForm , set the MainForm.Visible = false;
2. In MainForm.On_Load() event handler, show the Login Dialog
and you can call Close() in this handler.
3. if login ok , then set the MainForm.Visible = true;
If you have problem with this, please let me know.
Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" shouldbe removed before
sending, Thanks!

--------------------
| From: "Alejandro Casal" <[email protected]>
| Subject: Login dialog
| Date: Tue, 23 Sep 2003 19:07:04 +0200
| Lines: 15
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
| Message-ID: <#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: ip503d4c11.speed.planet.nl 80.61.76.17
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:52946
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| Hi there,
|
| I'm writing a .net Windows application in C#. I have 2 forms: the MainForm
| and the Login. The MainForm opens the Login as Dialog from the MainForm's
| constructor, and Login asks for username/password. I get these data from
the
| MainForm and check using a Web service that they're ok. If
username/password
| are not ok, I want to close the whole application, but I don't know how
| (this.Close() doesn't work). Can I close the app from the MainForm's
| constructor? Should I call the Login dialog and web service somewhere
else?
|
| Thanks,
|
| Alejandro.
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top