{"id":212,"date":"2009-04-11T12:21:39","date_gmt":"2009-04-11T12:21:39","guid":{"rendered":""},"modified":"2009-04-11T12:21:39","modified_gmt":"2009-04-11T12:21:39","slug":"212","status":"publish","type":"post","link":"https:\/\/www.poloo.org\/?p=212","title":{"rendered":"\u904d\u5386\u9875\u9762\u4e0a\u7684\u6587\u672c\u6846"},"content":{"rendered":"<p>&nbsp;&nbsp;\u5728WEB\u7a0b\u5e8f\u5f00\u53d1\u65f6\uff0c\u7ecf\u5e38\u9700\u8981\u505a\u4e00\u4e9b\u9875\u9762\u4e0a\u591a\u4e2a\u63a7\u4ef6\u7684\u76f8\u540c\u64cd\u4f5c\uff0c\u6bd4\u5982\u6e05\u7a7a\u3001\u8d4b\u503c\u7b49\u7b49\u3002\u4e0b\u9762\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u4e00\u4e0b\u89e3\u51b3\u65b9\u6cd5\uff1a<br \/>1.\u6574\u4e2a\u9875\u9762\u7684\u5224\u65ad <br \/><code><br \/>foreach(Control ctl in this.Controls[1].Controls)<br \/>{<br \/> if(ctl.GetType().Name==\"TextBox\")<br \/> {<br \/>&nbsp;&nbsp;TextBox tb =new TextBox();<br \/>&nbsp;&nbsp;tb=(TextBox)this.FindControl(ctl.ID);<br \/>&nbsp;&nbsp;<br \/>&nbsp;&nbsp;if(tb.Text==string.Empty)<br \/>&nbsp;&nbsp;{<br \/>&nbsp;&nbsp; Response.Write(\"&lt;script&gt;alert('\" + ctl.ID + \"\u7684\u503c\u4e3a\u7a7a\u3002');&lt;\/script&gt;\");<br \/>&nbsp;&nbsp; break;<br \/>&nbsp;&nbsp;}<br \/> }<br \/>}<br \/><\/code><br \/>2.\u6307\u5b9aformID\u91ccTextBox \u5224\u65ad<br \/>\u5148\u627e\u51fa\u4f60\u7684Form\u7684ID<br \/><code><br \/>protected HtmlForm yourformID;<br \/>foreach (object obj in yourformID.Controls)<br \/>{<br \/>&nbsp;&nbsp; if (obj is TextBox)<br \/>&nbsp;&nbsp; {<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TextBox tb = (TextBox)obj;<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (tb.Text = string.Empty)<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.Write(\"&lt;script&gt;alert('\" + tb.ID + \"\u7684\u503c\u4e3a\u7a7a\u3002');&lt;\/script&gt;;\")<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br \/>&nbsp;&nbsp; }<br \/>}<br \/><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;\u5728WEB\u7a0b\u5e8f\u5f00\u53d1\u65f6\uff0c\u7ecf\u5e38\u9700\u8981\u505a\u4e00\u4e9b\u9875\u9762\u4e0a\u591a\u4e2a&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-212","post","type-post","status-publish","format-standard","hentry","category-NET"],"_links":{"self":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=212"}],"version-history":[{"count":0,"href":"https:\/\/www.poloo.org\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.poloo.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}