ASP. net mvc + LINQ develop a book sales site (8): Form Verification

Source: Internet
Author: User

We use addcategory (for example, the page for adding a library directory). We require that the directory name cannot be blank.

1. Modify addcategory. aspx

2. Create a New formvalidate. js file in the content directory.

3. We can't forget the backend verification and modify the categorycontroller.

Question 1: I originally wanted to return directly if it is empty, but the page is blank, I can only rerender view the current page, but if there is data from the last request on the page, I can only re-execute the previous action. If there is no parameter, it will take, if there is a parameter, do you have to save it all, that friend knows?

4. Results

A. No input content, focus left

B. After the content is entered, the focus is removed.

Question 2: If this is used, you have to write JavaScript yourself. How can the convenient Verification Mechanism of webform be used in MVC?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.