Solved

cookies in windows form?

Posted on 2007-11-21
11
661 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 200 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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 100 total points
ID: 20328576
0
 
LVL 8

Assisted Solution

by:Autoeforms
Autoeforms earned 100 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 100 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
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 …

751 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