使用会话重定向到另一个页面 [英] Using session redirect to another page

查看:74
本文介绍了使用会话重定向到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

登录界面如下;





学生ID textbox1



学生姓名textbox2







结果屏幕如下;





您通过的通缉标记是80%



下一个候选人(按钮)





如果学生通过下一位候选人可以参加考试





如果假设学生失败则显示消息,



抱歉,您失败了,您必须参加现在在屏幕上显示的重新考试



当学生失败时,它将重定向到登录页面。

在该登录页面中我想通过会话传递学生ID和学生姓名并显示到登录屏幕的textbox1和textbox2。



我该怎么办。



请帮帮我。



问候,

奈良siman P.

解决方案

当学生填写登录屏幕中的所有详细信息时,您正在检查他/她是否从DataBase通过。



首先,在登录期间,您可以将值存储在 Session [StudentId] 会话中[StudentName]



因此,数据库查询中的逻辑可能如下所示...



如果学生通过

显示你的通过通知标记是......
Else

从DataBase中获取学生ID和学生姓名。如果您还没有登录,请在会话中存储。
将其重定向到登录页面。
在会话登录时直接访问输入的项目(如果已存储)。



如果您将使用Session,请按以下方式执行...

 txtStudentId.Text = Session [  StudentId]。Tostring(); 
txtStudentName.Text = Session [ StudentName]。ToString();


Login screen as follows;


Student id textbox1

student name textbox2



Result screen as follows;


Your are passed congrultions marks is 80%

Next Candidate (Button)


if the student pass next candidate can attend the exam


if suppose student is fail shows the message,

sorry you are failed you have to attend the reexam now display in the screen

that time when student fail it will redirect to Login page.
in that login page i want to pass the student id and student name from database using session and display into the textbox1 and textbox2 of the login screen.

for that how can i do.

please help me.

Regards,
Narasiman P.

解决方案

When the student fills all details in login screen, you are checking whether he/she is passed or not from DataBase.

First of all during login, you can store both the values in Session["StudentId"] and Session["StudentName"].

So, the logic in your DataBase Query may be like below in result screen...

If student is passed

   display "Your are passed congrultions marks is..."
Else
  
   Fetch the student id and student name from DataBase. Store in Session, if you have not at the time of Login.
   Redirect it to Login Page. 
   Or directly access the entered items at the time of login from Session, if you have stored them. 


If you will use Session, then do it like below...

txtStudentId.Text = Session["StudentId"].Tostring();
txtStudentName.Text = Session["StudentName"].ToString();


这篇关于使用会话重定向到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆