[英]How to return a message when a try to login to the website failed, because the user does not exist/password/username arent correct?
I built a website as my project for school. 我建立了一个网站作为我的学校项目。 I built a registration system, but I have a problem: I want the user to recive a message from the server when the login proccess fails, and everything goes right, except from the message.
我建立了一个注册系统,但是有一个问题:我希望用户在登录过程失败时从服务器接收一条消息,并且一切正常,除了该消息。 Somehow, though everything is right, the user doesnt get any message from the server at all.
无论如何,尽管一切正常,但用户根本没有从服务器收到任何消息。 He is only redirected, as the code is programmed.
仅当代码被编程时,他才被重定向。 I followed the course of events and it seems that it should show a message, but in reality its not.
我遵循事件的过程,似乎它应该显示一条消息,但实际上它不是。
Im using aspx. 我正在使用aspx。
MasterPage.aspx: MasterPage.aspx:
<section>
<table id='tblog' border='0'>
<%=hello %>
<%=logIn %>
<%=topPanel %>
<%=msgError %>
</table>
</section>
MasterPage.aspx.cs MasterPage.aspx.cs
public string msgError = "";
if (Request.Form["submit1"] != null)
{
nameen = Request.Form["nameen"];
password = Request.Form["password"];
query = "select * from Users";
query += " WHERE Name = '" + nameen + "'";
query += " AND PWD = '" + password + "'";
SqlDataReader data = DalBll.DataReadSQL(DalBll.GetConnection(), query);
if (data.Read())
{
///(I DELETED THIS PART)
}
else
{
msgError += "<tr><td colspan='2'><div>WRONG PASSWORD/USERNAME</div></td></tr>";
}
Response.Redirect("Default.aspx");
}
There are many documented ways to display information to the user. 有许多记录的方法可以向用户显示信息。 One way to do this is to use a javascript alert.
一种方法是使用javascript警报。
Replace Response.Redirect()
with this: 用以下内容替换
Response.Redirect()
:
ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + msgError + "');", true);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.