TextBox-Control 的 MaxLength 属性有多可靠?

8

本文介绍了TextBox-Control 的 MaxLength 属性有多可靠?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

TextBox 控件提供 MaxLength 属性,允许在该 TextBox 中插入的文本被客户端限制为指定数量的字符.

The TextBox control offers a MaxLength property, which allows the insertable text into that TextBox be clientside limited to the specified amount of chars.

我的问题:

  • 此属性是否仅在客户端和因此依赖于浏览器?
  • 我可以相信这样一个事实,即Text 属性包含的文本不超过MaxLength 已设置(仅适用于MSDN 中命名的 DisplayModes文章)还是我必须手动执行 TextBox.Text.SubString(0,所需最大长度)?
  • 这一切是怎么回事使用禁用的 java 脚本?

推荐答案

它不依赖于javascript,但这并不安全.

It does not depend on javascript but that does not make it safe.

任何人仍然可以使用 javascript(例如 XmlHttpRequest)发布请求,或者只是制作一个请求以发送比最大长度规范更多的数据.这是阻止普通用户过度填充字段的好方法,但无论如何您都需要在服务器上仔细检查.

Anyone can still post a request using javascript (XmlHttpRequest for example) or just craft a request to send more data than the max-length specification. It's a good way to stop a normal user from over populating a field but it is something you need to double check on the server anyway.

这篇关于TextBox-Control 的 MaxLength 属性有多可靠?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

C# 中的多播委托奇怪行为?
Multicast delegate weird behavior in C#?(C# 中的多播委托奇怪行为?)...
2023-11-11 C#/.NET开发问题
6

参数计数与调用不匹配?
Parameter count mismatch with Invoke?(参数计数与调用不匹配?)...
2023-11-11 C#/.NET开发问题
26

如何将代表存储在列表中
How to store delegates in a List(如何将代表存储在列表中)...
2023-11-11 C#/.NET开发问题
6

代表如何工作(在后台)?
How delegates work (in the background)?(代表如何工作(在后台)?)...
2023-11-11 C#/.NET开发问题
5

没有 EndInvoke 的 C# 异步调用?
C# Asynchronous call without EndInvoke?(没有 EndInvoke 的 C# 异步调用?)...
2023-11-11 C#/.NET开发问题
2

Delegate.CreateDelegate() 和泛型:错误绑定到目标方法
Delegate.CreateDelegate() and generics: Error binding to target method(Delegate.CreateDelegate() 和泛型:错误绑定到目标方法)...
2023-11-11 C#/.NET开发问题
14