如何在单击按钮中清除文本框和标签值? [英] How to clear both textbox and label value in single button click?

查看:142
本文介绍了如何在单击按钮中清除文本框和标签值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我hava登录表单中有包含登录面板的adiv,我需要在用户提供错误的凭据时清除文本框和标签值。对于意外提供错误详细信息的用户来说,这看起来很酷......任何帮助将不胜感激...

i hava login form within that have adiv that contains login panel in that i need to clear both textbox and label value when user gives wrong credentials. This will look cool for the user who accidentally gives wrong details... Any Help Will be appreciated...

推荐答案

在按钮点击事件中,如果用户身份验证失败,设置文本框的文本属性并将标签设置为空字符串。

类似于:

In the button click event, if the user authentication fails, set the text propert of your textbox and label to empty string.
Something like:
protected void Button1_Click(object sender, EventArgs e)
{
    //if user authentication failed
    TextBox1.Text = "";
    Label1.Text = "";
    //lblErrorMessage = "Invalid Username or Password!";
}





标签是什么?



您还应该有一个标签通知用户身份验证失败(我在代码中添加了该注释)。



What is the label for?

You should also have a label which notifies the user about the authentication failure (I have added that as a comment in the code).


这篇关于如何在单击按钮中清除文本框和标签值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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