473,499 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Basic question about login form and passing success back to main form

It's been longer that I remember since writing windows (not web) apps.

1) I want to load a main form

2) User clicks login button which brings up login form (on top of main form)

3) Upon entering successful password and clicking ok, login form should go
away

4) Main form should then display admin controls

I'm not sure how this code should look. How should success be passewd back
to the main form? If the main form is already loaded (just behind the login
form), how then do I "reload" (or whatever) to let it know it should show
some admin controls?

Thanks for any help!
RC
Dec 28 '05 #1
5 1979
Hi,

"Ronald S. Cook" <rc***@westinis.com> wrote in message
news:Ok**************@TK2MSFTNGP14.phx.gbl...
It's been longer that I remember since writing windows (not web) apps.

1) I want to load a main form

2) User clicks login button which brings up login form (on top of main
form)

3) Upon entering successful password and clicking ok, login form should go
away

4) Main form should then display admin controls

I'm not sure how this code should look. How should success be passewd
back to the main form? If the main form is already loaded (just behind
the login form), how then do I "reload" (or whatever) to let it know it
should show some admin controls?

A very simple way of solving this is displaying the login as a modal
windows (which probably you use ) , set the DialogResult accordingly and if
the correct value is received show the controls:

//you can use any of the values of DialogResult
if ( theLoginForm.ShowDialog() == DialogResult.Yes )
SetAdminControlsVisible();
Btw, you use Form.DialogResult = ... inside the form. probably like

void button1_onclick(.... )
{
if( Islogincorrect( textbox1.Text, textbox2.Text) )
{
this.DialogResult = DialogResult.Yes;
this.Close();
}
}

How to make the controls visible depends of your form and the controls, you
can simple do a Control.Visible = true; to all the controls you need.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Thanks for any help!
RC

Dec 28 '05 #2
Actually once you set the DialogResult of a form you don't need to call
this.Close(). Setting the DialoResult seems to take care of that from what
I have seen.

Eric Renken

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.machin AT dot.state.fl.us> wrote
in message news:e3****************@TK2MSFTNGP15.phx.gbl...
Hi,

"Ronald S. Cook" <rc***@westinis.com> wrote in message
news:Ok**************@TK2MSFTNGP14.phx.gbl...
It's been longer that I remember since writing windows (not web) apps.

1) I want to load a main form

2) User clicks login button which brings up login form (on top of main
form)

3) Upon entering successful password and clicking ok, login form should
go away

4) Main form should then display admin controls

I'm not sure how this code should look. How should success be passewd
back to the main form? If the main form is already loaded (just behind
the login form), how then do I "reload" (or whatever) to let it know it
should show some admin controls?

A very simple way of solving this is displaying the login as a modal
windows (which probably you use ) , set the DialogResult accordingly and
if the correct value is received show the controls:

//you can use any of the values of DialogResult
if ( theLoginForm.ShowDialog() == DialogResult.Yes )
SetAdminControlsVisible();
Btw, you use Form.DialogResult = ... inside the form. probably like

void button1_onclick(.... )
{
if( Islogincorrect( textbox1.Text, textbox2.Text) )
{
this.DialogResult = DialogResult.Yes;
this.Close();
}
}

How to make the controls visible depends of your form and the controls,
you can simple do a Control.Visible = true; to all the controls you need.

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

Thanks for any help!
RC


Dec 28 '05 #3
Eric Renken <Er*********@newsgroup.nospam> wrote:
Actually once you set the DialogResult of a form you don't need to call
this.Close(). Setting the DialoResult seems to take care of that from what
I have seen.


Fortunately it's more than "seems to" (which would be a dodgy thing to
rely on, IMO). It's nicely documented:

(From the DialogResult property docs.)

<quote>
If the form is displayed as a dialog box, setting this property with a
value from the DialogResult enumeration sets the value of the dialog
box result for the form, hides the modal dialog box, and returns
control to the calling form
</quote>

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Dec 29 '05 #4
Hi,


(From the DialogResult property docs.)

<quote>
If the form is displayed as a dialog box, setting this property with a
value from the DialogResult enumeration sets the value of the dialog
box result for the form, hides the modal dialog box, and returns
control to the calling form
</quote>

Yep, always RTFM first :)


--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Dec 29 '05 #5
I guess to me it always works fine because when I display a modal dialog
like this I always have them wrapped in a using statement so when it is
finished I know it will be disposed of.

using ( Form myModal = new AskAQuestion() )
{
myModal.ShowDialog();
}

Eric Renken

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP***********************@msnews.microsoft.co m...
Eric Renken <Er*********@newsgroup.nospam> wrote:
Actually once you set the DialogResult of a form you don't need to call
this.Close(). Setting the DialoResult seems to take care of that from
what
I have seen.


Fortunately it's more than "seems to" (which would be a dodgy thing to
rely on, IMO). It's nicely documented:

(From the DialogResult property docs.)

<quote>
If the form is displayed as a dialog box, setting this property with a
value from the DialogResult enumeration sets the value of the dialog
box result for the form, hides the modal dialog box, and returns
control to the calling form
</quote>

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Jan 12 '06 #6

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

Similar topics

7
9260
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
1
2134
by: John Davis | last post by:
I put a little login (username and password textfields) in a web page, and once the user able to login, I want the username and password textfields will disappear, and replace with text " has...
2
1547
by: Jerry Spence1 | last post by:
One way of passing data to a thread is to encapsulate the thread inside a class. However, I can't refer to my main form objects from within the class/thread as it says "Reference to a non-shared...
6
4684
by: BizWorld | last post by:
Hi, I have a scenario where i need to configure only Login.aspx page to use SSL. All other application will run on HTTP protocol. If someone can guide me how to accomplish this. One of my idea...
4
1339
by: garyusenet | last post by:
I have a login form, which i have made by simply modifying the standard wizard created form from Visual C# express - when I chose a windows application. I have two buttons on my login form. ...
10
22302
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...
1
3310
by: Kandiman | last post by:
Hiya, i made a asp page, and one of my divs (as a include) is as below. the problem is if the main page is resubmitted, i get logged out again?... heres the code.. i think its on the value=true...
1
4098
by: RLN | last post by:
RE: Access 2003 After the user puts in the password to log in, (in frmLogin, I am displaying the main data entry form. That all works great, but now I cannot close the Login form (behind the...
10
4794
by: DavidPr | last post by:
When I logout as one user and log in under a different user, it opens with the last user's information. User 1 - Unsername: Davey Jones User 2 - Unsername: David Smith I log out from Davey...
0
7014
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7229
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...
1
6905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7395
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4921
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3108
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3103
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.