Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem of invalid MaxLength property setting of ASP.NET in MVC

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains the "ASP.NET in MVC MaxLength feature setting invalid problem how to solve", the article explains the content is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in-depth, together to study and learn "ASP.NET in MVC MaxLength feature setting invalid problem how to solve" it!

1. Question:

In the ASP.NET MVC project, the MaxLength feature is added to a Model as follows:

The copy code is as follows:

Public class SomeClass

{

[MaxLength (16, ErrorMessage = "maximum length 16")]

Public string SomeProperty {get;set;}

}

However, there is no similar data-val-length attribute in its corresponding form element.

Second, the solution: use StringLength instead of MaxLength.

The copy code is as follows:

Public class SomeClass

{

[StringLength (16, ErrorMessage = "maximum length 16")]

Public string SomeProperty {get;set;}

}

Thank you for your reading, the above is the "ASP.NET in MVC MaxLength feature setting invalid problem how to solve" the content, after the study of this article, I believe you on ASP.NET in MVC MaxLength feature setting invalid problem how to solve this problem has a deeper understanding, the specific use of the need for you to practice verification. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report