当 Textbox.TextMode=“Password” 时,ASP.net 中的 CustomValidator 为空

发布于 2024-10-09 18:04:31 字数 224 浏览 0 评论 0原文

当 Textbox.TextMode="Password" 时,ASP.net 中的 CustomValidator 为空。 我调用服务器方法并尝试获取 value.Value。

当我将 TextMode 更改为 SingleLine 或 MultiLine 时,一切正常。 当我将其设置为密码时,该值为空。

但对我来说,没有 textmode=password 就没有办法做到这一点,那么该怎么办呢?

my CustomValidator in ASP.net is empty when Textbox.TextMode="Password".
I call a server-method and try to get the value.Value.

When I change the TextMode to SingleLine or MultiLine all works fine.
When I have it to Password the value is empty.

But for me there is no way to do it without textmode=password, so what to do there?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风为裳 2024-10-16 18:04:31

不是从 args.Value 获取值,而是直接从文本框获取值,如下所示:

protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
        {
            string pwd = txtPwd.Text;
            if (pwd == "something")
            {
                args.IsValid = false;
            }
            else
            {
                args.IsValid = true;
            }
        }

Instead of getting value from args.Value you get it from the textbox directly like:

protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
        {
            string pwd = txtPwd.Text;
            if (pwd == "something")
            {
                args.IsValid = false;
            }
            else
            {
                args.IsValid = true;
            }
        }
最单纯的乌龟 2024-10-16 18:04:31

我相信这是出于安全目的的标准行为。

I believe that is standard behavior for security purposes.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文