Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
143 views
in Technique[技术] by (71.8m points)

asp.net - Save state of html to database

I am doing Project by asp.net. Some states of changing themes of page (setting allows users to change private themes).

For example: I used "jquery about sortable list". Users can sort position of items in this list. But i don't know how to save state of items after sorted by users for each user who did it.

List menu: Home About Default

Position of Home, About, Default can exchange for each others by user's sorting.

How to save sorting to DataBase for each user.

Tks !

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I think the best approach is: do not re-invent the wheel

ASP.Net contains something called: User Profiles

They work by storing user preferences and they work for both, anonymous and authenticated users.

When a user is anonymous, his profile is stored in cookies. When the user becomes authenticated, you can migrate the existing anonymous profile to store it in the database.

ASP.Net contains functionality to do all this job for you. You can even access the profile properties using JavaScript

I already answer a couple of questions that can explain the process:

How to persist anon user selection (ex: theme selection)

accessing profile.newproperty in MVC web applications

Note: If you are using a Web Application instead of a Website, then the answer provided in the first link won't work, that's because the Profile class is pre-compiled only when using a Website. In order to implement the profiles functionality, you should create a custom class and inherit from ProfileBase. You can use the code specified in the second link, even when that example is made specifically for MVC, the profile class, and the profile registration in the web.config are the same for any Web Application


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...