Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

cookies in windows form?

Posted on 2007-11-21
11
Medium Priority
?
665 Views
Last Modified: 2010-04-21
I'm an ASP.Net developer and web has "cookies" to save user's selection.

What's equal to Cookies in WinForm? In my login page, I have 2 radiobutons. I dont want the user to keep selecting them everytime they login. How can I save this user selection in a cookie?

I'm a VB.Net-er but for this, I'm using C# to learn C#.
0
Comment
Question by:Camillia
  • 4
  • 3
  • 2
  • +2
11 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20328464
You can save user preferences in Windows registry. To save, you can do something like:

                RegistryKey regKey = Application.CommonAppDataRegistry;
                regKey.SetValue("LoginName", loginname);

To retrieve:

                RegistryKey regKey = Application.CommonAppDataRegistry;
                loginname = regKey.GetValue("LoginName").ToString();
0
 
LVL 20

Accepted Solution

by:
REA_ANDREW earned 800 total points
ID: 20328470
Add a settings file and declare the scope as User not Application

Andrew
0
 
LVL 7

Author Comment

by:Camillia
ID: 20328479
Thanks.I thought about the registery since our vendor app does that. But i thought there's a way around not playing around with a registery. Maybe save in a config file or something . But I'll try that.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 7

Author Comment

by:Camillia
ID: 20328538
Then how to save/retreive in the settings File. I added it. Do see the "User" dropdown? User's name needs to be saved in that??
0
 
LVL 20

Expert Comment

by:REA_ANDREW
ID: 20328556
OK so say you simply add a new settings file and it is callded Settings1.settings.  It is simply this:

Settings1.Default.Username = "Andy";

where Username is the name of the setting which I have declared as type string and scope User

Andrew

:-)
0
 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 400 total points
ID: 20328576
0
 
LVL 8

Assisted Solution

by:Autoeforms
Autoeforms earned 400 total points
ID: 20328581
If you do not want to save info to the registry you can save it to a config file using serialization.  This is the strategy I use.  Plus I store the info in the directory on the server so it is available regardless of the machine they log into.

http://www.java2s.com/Code/VB/File-Directory/Serialize-to-XML.htm

good luck
Greg
0
 
LVL 7

Author Comment

by:Camillia
ID: 20328591
let me read. I did this : Settings1 userSetting = new Settings1();

but seems like that's an overkill. Thanks Jaime, let me read the links.
0
 
LVL 70

Assisted Solution

by:Éric Moreau
Éric Moreau earned 400 total points
ID: 20328783
0
 
LVL 20

Expert Comment

by:REA_ANDREW
ID: 20329524
?

No it is static, do not instantiate anything:

Simply

Settings1.Default.Username

0
 
LVL 7

Author Closing Comment

by:Camillia
ID: 31410382
thanks. have another question but will close this. It works great.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question