473,373 Members | 1,415 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,373 software developers and data experts.

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 1973
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
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
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
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
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
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
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
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
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
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel

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.