Solved

cookies in windows form?

Posted on 2007-11-21
11
657 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
Comment Utility
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
Comment Utility
Add a settings file and declare the scope as User not Application

Andrew
0
 
LVL 7

Author Comment

by:Camillia
Comment Utility
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
 
LVL 7

Author Comment

by:Camillia
Comment Utility
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
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 55

Assisted Solution

by:Jaime Olivares
Jaime Olivares earned 100 total points
Comment Utility
0
 
LVL 8

Assisted Solution

by:Autoeforms
Autoeforms earned 100 total points
Comment Utility
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
Comment Utility
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 69

Assisted Solution

by:Éric Moreau
Éric Moreau earned 100 total points
Comment Utility
0
 
LVL 20

Expert Comment

by:REA_ANDREW
Comment Utility
?

No it is static, do not instantiate anything:

Simply

Settings1.Default.Username

0
 
LVL 7

Author Closing Comment

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

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now