问题描述
大家好,
我已经开发了一个Web应用程序,当用户返回时,所有条目都已过期.我希望当用户返回时,可以看到他们在最后一页上输入的所有条目.
例如,如果用户输入如下内容:
第一页:用户名,User_ID
第二页:Q1
第三页:第二季度
第四页:第三季度
第五页:第四季度
第六页:完整
在数据库中,答案将根据用户ID保存.查询就像:
更新Q1 ="value",其中User_ID = @User_ID
更新Q2 ="value",其中User_ID = @User_ID
更新Q3 ="value",其中User_ID = @User_ID
因此,如果用户想再次编辑Q2,那么他可以返回并编辑最后一个答案,但是在我的情况下,当用户返回时,他的最后一个答案将保存在数据库中,而不是保存在页面上.因此,我希望他在完成之前可以查看或编辑以前的答案,然后就可以对其进行编辑.
为此,我使用了此解决方案........
Response.Redirect("Next_Page.aspx");
获取控件的值后的某个位置.在此行之前,添加您要存储的控制值的代码
如下所示-Session ["UserName"] = txtUserName.Text;
会话["UserID"] =用户ID;
等等.然后在上一页加载中检查这些值是否在会话中,
然后将值填充到如下所示的适当控件中...
内部Page_Load()---- if(Session ["UserName"]!= NULL){txtUserName.Text = Session ["UserName"].ToString(); }
if(Session ["UserID"]!= NULL){txtUserID.Text = Session ["UserID"].ToString(); }等等.....
为了结束会话,我在应用程序的最后一页和终止页面上使用了session.abendon属性.
它可以工作,但是会保存我每次使用此应用程序时输入的值,以及如果有一个以上的用户同时使用此应用程序,该操作将保存,因为它始终显示会话中存储的相同值?
任何帮助表示赞赏.
谢谢.
Hi All,
I have developed a web application and the when user goes back all the entries are expired. I want that when user goes back, all the entries they entered on the last page are viewable.
For example if a user entered like :
first page : User Name,User_ID
Second Page : Q1
Third Page : Q2
Fourth Page : Q3
Fifth Page : Q4
Sixth Page : Complete
In database answer will save according to User ID. Query is like :
Update Q1= "value" where User_ID = @User_ID
Update Q2= "value" where User_ID = @User_ID
Update Q3= "value" where User_ID = @User_ID
So if user want to edit Q2 again then he can go back and edit the last answer but in my case when user go back then his last answer will save in database but not on the page. So i want whenever he want to review or edit the previous answers before complete he can go and edit it.
for this i have used this solution...........
Response.Redirect("Next_Page.aspx");
somewhere after getting the values of the controls. Just before this line add the codes for the conrol values u want to store
like below - Session["UserName"] = txtUserName.Text;
Session["UserID"] = UserID;
and so on..... And then in previous page load check whether these value are in session or not,
then fill values to appropriate controls as below...
Inside Page_Load() ---- if(Session["UserName"] != NULL) { txtUserName.Text = Session["UserName"].ToString(); }
if(Session["UserID"] != NULL) { txtUserID.Text = Session["UserID"].ToString(); } and so on.....
For ending the session i have used session.abendon property on the last page and on the terminate page of the application.
It work''s but it saves the value i have entered for every time i use this application and what if more then one user use this application at the same time, because it show''s all the time same value stored in the session ?
Any help is appreciated.
Thanks.
推荐答案
这篇关于会话存储数据,并在每次使用该应用程序时显示相同的值.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!