質問

Why doesn't my page redirect? The "Valid user" prompt pops up. But my page just does not redirect. What can be the issue?

protected void LoginButton_Click1(object sender, EventArgs e)
{
if (Page.IsValid)
{
User userLogin = new User();
userLogin.userId = this.txtUserName.Text.Trim();
userLogin.userPwd = this.txtPwd.Text.Trim();

string result = CommonFunctions.Check_ValidUser(userLogin);

if (result == "s")
{
Response.Write("<script>alert('" + "Valid user"+ "') ; location.href='Login.aspx'</script>");
Response.Redirect("DrugEntry.aspx",true);
}
else
{
string message = "We don't seem to have this user registered. Please try again.";
Response.Write("<script>alert('" + message + "') ; 
location.href='Login.aspx'</script>");
}
}
}
役に立ちましたか?

解決

It seems that your code is correct.

Make sure that your page is in the same directory. If it is not in the same directory that use it as mentioned in below sample :

Response.Redirect("[Directory Name]/DrugEntry.aspx",true);
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top