当我在文本框文本更改事件上应用此代码时,我如何...检查密码长度是ASP.NET [英] How do i...check password length is ASP.NET while I apply this code on textbox text change event

查看:45
本文介绍了当我在文本框文本更改事件上应用此代码时,我如何...检查密码长度是ASP.NET的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何检查密码它不起作用

我如何...检查密码长度是asp.net而我在文本框文本更改事件上应用此代码



我尝试过:



受保护的子密码盒_TextChanged(发件人为对象,e为EventArgs)处理PasswordBox.TextChanged

如果PasswordBox.Text.Length< = 4那么

Label9.Visible = True

label9.text =密码必须是6-8个字符





结束如果

结束Sub

how i do check password it does not work
How do I...check password length is asp.net while i apply this code on textbox text change event

What I have tried:

Protected Sub PasswordBox_TextChanged(sender As Object, e As EventArgs) Handles PasswordBox.TextChanged
If PasswordBox.Text.Length <= 4 Then
Label9.Visible =True
label9.text="Password must be 6-8 character"


End If
End Sub

推荐答案

它不起作用可能是我们在这里得到的最无用的错误描述 - 我们得到了很多。它没有告诉我们任何事情:我们知道它不起作用,因为如果确实如此,你就不会问这个问题了!

告诉我们*它如何*它不起作用:什么这样做是你没想到的,还是不这样做?你是怎么测试的?发生了什么?有错误信息吗?这些代码如何适合你的应用程序的其余部分?



但更重要的是,你为什么要在服务器上这样做呢?您是否在页面加载事件中检查了IsPostBack?

检查密码长度是一个本地的事情:在客户端的JavaScript中执行,而不是在服务器的VB中执行! Google:在javascript中检查密码长度 [ ^ ]

你这样做的方式,每次按键都要产生一个帖子回到服务器并回复客户回复...
"it does not work" is probably one the most useless error descriptions we get here - and we get it a lot. It tells us nothing: we know it "doesn't work" because if it did you wouldn't be asking a question about it!
Tell us *how* it doesn't work: what does it do that you didn't expect, or not do that you did? How did you test it? What did happen? Any error messages? How does that code fit into the rest of your app?

But more importantly, why are you trying to do that at the server? Have you checked IsPostBack in your Page Load event?
Checking the password length is a "local" thing: do it in JavaScript at the Client, not in VB at the Server! Google: checking password length in javascript[^]
The way you do it, every keystroke has to generate a post back to the server and a round trip back to the client with the response...


这篇关于当我在文本框文本更改事件上应用此代码时,我如何...检查密码长度是ASP.NET的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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