在网页上显示错误消息 [英] Display error message on web page

查看:98
本文介绍了在网页上显示错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果用户输入无效的凭据,我想在登录页面上显示错误消息.

有人可以帮我吗?

I want to display an error message on my login page if the user enters invalid credentials.

Can anyone help me with that?

推荐答案

这真的是基本的ASP.NET.从此处开始: http://msdn.microsoft.com/en-us/library/ms178331(v = VS.90).aspx [ ^ ]
This is really basic ASP.NET. Start here: http://msdn.microsoft.com/en-us/library/ms178331(v=VS.90).aspx[^]


我不会为该问题提供任何链接,但会为您提供尝试的步骤.

步骤:
1.在页面上保留可见性为false的标签(您可以将其放置在登录按钮下方的某处)
2.在登录按钮上单击,检查登录凭据.如果发现错误,则将标签的可见性设置为true并设置该标签的文本.

试试吧!
I won''t give any link for this question but steps for you to try.

Steps:
1. Keep a label with Visibility as false on your page (you can place it somewhere below login button)
2. On login button click, check for login credentials. If found wrong then set the visibility of the label true and set the text of that label.

Try!


嘿,
您可以在按下登录按钮后注册客户端脚本.并显示一条JavaScript警报消息.

例如
hey,
you can register a client script after the login button is pressed. and show a javascript alert message.

e.g.
if (Validated)
{
//do stuff;
}
else
{
ScriptManager.RegisterClientScriptBlock(Me.Page, Me.GetType(), "ShowError", "return InvalidLogin();", True)
}





并在页面的标记中添加脚本





and in the markup of your page add the script

<script type="text/javascript">
function InvalidLogin()
{
alert("Invalid username or password");
return false;
}




祝你好运
Ahsan Sarfraz




best of luck
Ahsan Sarfraz


这篇关于在网页上显示错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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