divinediu
divinediu

Reputation: 433

Page is not redirecting C# ASP.net

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>");
}
}
}

Upvotes: 1

Views: 1738

Answers (1)

Chirag Adhvaryu
Chirag Adhvaryu

Reputation: 342

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);

Upvotes: 1

Related Questions