ASP.NET - Validation \u670d\u52a1\u5668\u63a7\u4ef6<\/strong><\/div>\nValidation \u670d\u52a1\u5668\u63a7\u4ef6\u662f\u7528\u6765\u9a8c\u8bc1\u7528\u6237\u8f93\u5165\u7684\u3002\u5982\u679c\u7528\u6237\u8f93\u5165\u6ca1\u6709\u901a\u8fc7\u9a8c\u8bc1\uff0c\u5c06\u663e\u793a\u4e00\u6761\u9519\u8bef\u6d88\u606f\u7ed9\u7528\u6237\u3002<\/p>\n
\u6bcf\u79cd validation \u63a7\u4ef6\u6267\u884c\u4e00\u79cd\u6307\u5b9a\u7c7b\u578b\u7684\u9a8c\u8bc1\uff08\u6bd4\u5982\u9a8c\u8bc1\u67d0\u4e2a\u6307\u5b9a\u7684\u503c\u6216\u8005\u67d0\u4e2a\u8303\u56f4\u7684\u503c\uff09\u3002<\/p>\n
\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u5f53 Button\u3001ImageButton\u3001LinkButton \u63a7\u4ef6\u88ab\u70b9\u51fb\u65f6\uff0c\u4f1a\u6267\u884c\u9875\u9762\u9a8c\u8bc1\u3002\u60a8\u53ef\u4ee5\u8bbe\u7f6e CausesValidation \u4e3a false \uff0c\u6765\u963b\u6b62\u6309\u94ae\u63a7\u4ef6\u88ab\u70b9\u51fb\u65f6\u8fdb\u884c\u9a8c\u8bc1\u3002<\/p>\n
\u521b\u5efa Validation \u670d\u52a1\u5668\u63a7\u4ef6\u7684\u8bed\u6cd5\u662f\uff1a<\/p>\n
<asp:control_name id=\"some_id\" runat=\"server\" \/><\/pre>\n\u5728\u4e0b\u9762\u7684\u5b9e\u4f8b\u4e2d\uff0c\u6211\u4eec\u5728 .aspx \u6587\u4ef6\u4e2d\u58f0\u660e\u4e86\u4e00\u4e2a TextBox \u63a7\u4ef6\u3001\u4e00\u4e2a Button \u63a7\u4ef6\u3001\u4e00\u4e2a RangeValidator \u63a7\u4ef6\u3002\u5982\u679c\u9a8c\u8bc1\u5931\u8d25\uff0c\u6587\u672c \"The value must be from 1 to 100!\" \u5c06\u4f1a\u663e\u793a\u5728 RangeValidator \u63a7\u4ef6\u4e2d\uff1a<\/p>\n
\u5b9e\u4f8b<\/strong><\/p>\n<html>\r\n<body>\r\n<form runat=\"server\">\r\n<p>Enter a number from 1 to 100:\r\n<asp:TextBox id=\"tbox1\" runat=\"server\" \/>\r\n<br \/><br \/>\r\n<asp:Button Text=\"Submit\" runat=\"server\" \/>\r\n<\/p>\r\n<p>\r\n<asp:RangeValidator\r\nControlToValidate=\"tbox1\"\r\nMinimumValue=\"1\"\r\nMaximumValue=\"100\"\r\nType=\"Integer\"\r\nText=\"The value must be from 1 to 100!\"\r\nrunat=\"server\" \/>\r\n<\/p>\r\n<\/form>\r\n<\/body>\r\n<\/html><\/pre>\n<\/form>\n","protected":false},"excerpt":{"rendered":"\u4e0b\u9762\u5217\u51fa\u7684\u4ee3\u7801\u662f\u4ece\u4e0a\u4e00\u7ae0\u4e2d\u590d\u5236\u7684\uff1a <html> <body bgcolor=”yellow […]<\/p>\n","protected":false},"author":1470,"featured_media":237648,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-237653","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/237653","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1470"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=237653"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/237653\/revisions"}],"predecessor-version":[{"id":245832,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/237653\/revisions\/245832"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/237648"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=237653"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=237653"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=237653"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}