Asp.net server verification control failure

Source: Internet
Author: User

The problem is: When performing data verification on some textbox input boxes, the server data verification control is initially used. This is no problem. Later, some other textbox also needs to do some data verification. In this case, the server verification control is not used, but an onclientclick script is added to the button to verify the function judgeinput (). <Asp: button id = "btnsave" skinid = "buttonstyle" runat = "server" text = "save" onclick = "btnsave_click" onclientclick = "Return judgeinput (); "/>.

At this point, the problem is exposed. The data verification function in judgeinput () is normal, and all the previously used server data verification controls are invalid. It seems that I am not familiar with the internal mechanism of the server data verification control.

Solution:Add if (page_clientvalidate () {.../data verification at the beginning of the judgeinput () functionCode}.Solve the problem.

Summary: verify the data of the server data verification control. It is executed on the client. After the verification is passed, page_clientvalidate () returns true; otherwise, it is false. when onclientclick is not available, it is executed by default, but with the client function onclientclick, if page_clientvalidate () is not displayed, data verification of the server data verification control is not executed by default.

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.