Server.Tranfer和Response.Redirect的问题 [英] Problem with Server.Tranfer and Response.Redirect
问题描述
大家好
下面是检查用户是否存在于系统中的代码的代码
Hi guys
Below is the piec of code to check if user exist in the system
if ((txtLoginID.Text == dRow["EmpEmail"].ToString()) && txtPassword.Text == dRow["EmpPassword"].ToString() && ddlvalue==cli)
{
if ("Doctor" == dRow["EmpType"].ToString() || "Nurse" == dRow["EmpType"].ToString())
{
Server.Transfer("~/Employee/frmEmployeeHome.aspx?EmpIDNumber=" + dRow["EmpIDNumber"].ToString());// + "&EmpFullName=" + dRow["EmpFullName"].ToString() + "&EmpIDNumber=" + dRow["EmpIDNumber"].ToString() + "&Emptype=" + dRow["Emptype"].ToString());
found = true;
}
else
if ("Admin" == dRow["EmpType"].ToString())
{
Server.Transfer("~/Administration/frmTelerikScheduling.aspx");
found = true;
}
}
当我来到这一行时,"Server.Transfer("~/Administration/frmTelerikScheduling.aspx");
"
转到该页面...下面是"frmTelerikScheduling.aspx
"
中的代码
When I come to this line" Server.Transfer("~/Administration/frmTelerikScheduling.aspx");
"
It goes to that page...Now below is the code from "frmTelerikScheduling.aspx
"
protected void Page_Load(object sender, EventArgs e)
{
populateddlEmployeesOnPageLoad();
loadDDLServices();
loadDDlPatients();
getAppointments();
}
因此,我注意到我的应用程序读取了方法后便回到了登录表单
并阅读下面的代码
So i noticed after my application read the methods it goes back to the login form
and read the code below
public void loadDDlClinicName()
{
if (!Page.IsPostBack)
{
systemBusinessLayer = new BusinessLayer();
ArrayList clinicList = new ArrayList();
clinicList = systemBusinessLayer.getClinics();
ddlClinicName.DataSource = clinicList;
ddlClinicName.DataTextField = "ClinicName";
ddlClinicName.DataValueField = "ClinicRefNumber";
ddlClinicName.DataBind();
ddlClinicName.Items.Insert(0, ".:Select Clinic:.");
}
}
然后,它在此行中抱怨一个空对象"clinicList = systemBusinessLayer.getClinics();"
方法loadDDlClinicName()在登录页面的页面加载上运行
这很奇怪...我需要帮助
Then it complains about an empty object in this line "clinicList = systemBusinessLayer.getClinics();"
method loadDDlClinicName() runs on pageload of the login page
this weird...I need help
推荐答案
,根据您所提供的描述,很明显回发正在发生.如果您使用任何身份验证或授权,则可能导致此问题.
当DDLClinic的索引更改时,还有一件事是它再次调用load函数,因此请确保正确调试它以找到操作流程.
as per description u have given it is clear that postback is taking place. If u r using any authentication or authorization then that might be causing this problem.
One more thing as u r index is changing for DDLClinic it is calling the load function again so make sure u r debugging it correctly in order to find flow of the operation.
这篇关于Server.Tranfer和Response.Redirect的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!