{"id":112,"date":"2014-05-03T11:41:00","date_gmt":"2014-05-03T10:41:00","guid":{"rendered":"https:\/\/debuggersspace.com\/index.php\/2014\/05\/03\/types-of-validation-controls-in-asp-net\/"},"modified":"2014-05-03T11:41:00","modified_gmt":"2014-05-03T10:41:00","slug":"types-of-validation-controls-in-asp-net","status":"publish","type":"post","link":"https:\/\/debuggersspace.com\/index.php\/2014\/05\/03\/types-of-validation-controls-in-asp-net\/","title":{"rendered":"Types of Validation Controls in ASP.Net"},"content":{"rendered":"<div class='booster-block booster-read-block'>\n                <div class=\"twp-read-time\">\n                \t<i class=\"booster-icon twp-clock\"><\/i> <span>Read Time:<\/span>59 Second                <\/div>\n\n            <\/div><div dir=\"ltr\" style=\"text-align: left;\">\n<div style=\"clear: both; text-align: left;\">\n<a href=\"http:\/\/2.bp.blogspot.com\/-4kcVR503jyk\/U2S_YBDs1gI\/AAAAAAAAAzM\/oyKyv7oJFtA\/s1600\/Validator.JPG\" style=\"margin-left: 1em; margin-right: 1em;\" target=\"_blank\" rel=\"noopener\"><span style=\"font-family: Arial, Helvetica, sans-serif;\"><img loading=\"lazy\" decoding=\"async\" border=\"0\" src=\"http:\/\/2.bp.blogspot.com\/-4kcVR503jyk\/U2S_YBDs1gI\/AAAAAAAAAzM\/oyKyv7oJFtA\/s1600\/Validator.JPG\" height=\"131\" width=\"640\" \/><\/span><\/a><\/div>\n<div style=\"clear: both; text-align: center;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\"><br \/><\/span><\/div>\n<div style=\"clear: both; text-align: center;\">\n<a href=\"http:\/\/1.bp.blogspot.com\/-wrD22k18X2M\/U2TARByvDFI\/AAAAAAAAAzU\/duwrYQxVMYo\/s1600\/event.JPG\" style=\"margin-left: 1em; margin-right: 1em;\" target=\"_blank\" rel=\"noopener\"><span style=\"font-family: Arial, Helvetica, sans-serif;\"><img loading=\"lazy\" decoding=\"async\" border=\"0\" src=\"http:\/\/1.bp.blogspot.com\/-wrD22k18X2M\/U2TARByvDFI\/AAAAAAAAAzU\/duwrYQxVMYo\/s1600\/event.JPG\" height=\"240\" width=\"640\" \/><\/span><\/a><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\"><br \/><\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\"><b><u>Example for Custom validator<\/u><\/b><\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\"><b><u><br \/><\/u><\/b><\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\"><b><u>In&nbsp;Designer&nbsp;aspx<\/u><\/b><\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">&nbsp; &lt;asp:TextBox ID=&#8221;TextBox1&#8243; runat=&#8221;server&#8221;&gt;&lt;\/asp:TextBox&gt;<\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;asp:CustomValidator ID=&#8221;CustomValidator1&#8243; runat=&#8221;server&#8221;&nbsp;<\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ErrorMessage=&#8221;Not a even no&#8221; ControlToValidate=&#8221;TextBox1&#8243;&nbsp;<\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ForeColor =&#8221;Red&#8221; onservervalidate=&#8221;CustomValidator1_ServerValidate&#8221;<\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt;&lt;\/asp:CustomValidator&gt;<\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\"><\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">&nbsp; &nbsp; &nbsp; &nbsp; &lt;asp:Button ID=&#8221;Button1&#8243; runat=&#8221;server&#8221; Text=&#8221;Button&#8221; \/&gt;<\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\"><br \/><\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\"><b><u>In aspx.cs &nbsp;<\/u><\/b><\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)<\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">&nbsp; &nbsp; &nbsp; &nbsp; {<\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (Convert.ToInt32(args.Value) % 2 == 0)<\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; args.IsValid = true;<\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else<\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; args.IsValid = false;<\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<\/span><\/div>\n<div style=\"clear: both;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\">&nbsp; &nbsp; &nbsp; &nbsp; }<\/span><\/div>\n<div style=\"clear: both; text-align: center;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\"><br \/><\/span><\/div>\n<div style=\"clear: both; text-align: left;\">\n<span style=\"font-family: Arial, Helvetica, sans-serif;\"><a href=\"http:\/\/quickstarts.asp.net\/QuickStartv20\/aspnet\/doc\/validation\/\" target=\"_blank\" rel=\"noopener\">http:\/\/quickstarts.asp.net\/QuickStartv20\/aspnet\/doc\/validation\/<\/a><\/span><\/div>\n<div style=\"clear: both; text-align: left;\">\n<\/div>\n<div style=\"clear: both; text-align: left;\">\n<a href=\"http:\/\/www.codeproject.com\/Articles\/241066\/How-to-Validate-ASP-NET-Web-Forms-Using-Business-R\" target=\"_blank\" rel=\"noopener\">http:\/\/www.codeproject.com\/Articles\/241066\/How-to-Validate-ASP-NET-Web-Forms-Using-Business-R<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Example for Custom validator In&nbsp;Designer&nbsp;aspx &nbsp; &lt;asp:TextBox ID=&#8221;TextBox1&#8243; runat=&#8221;server&#8221;&gt;&lt;\/asp:TextBox&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;asp:CustomValidator ID=&#8221;CustomValidator1&#8243; runat=&#8221;server&#8221;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ErrorMessage=&#8221;Not a even no&#8221; ControlToValidate=&#8221;TextBox1&#8243;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ForeColor =&#8221;Red&#8221; onservervalidate=&#8221;CustomValidator1_ServerValidate&#8221; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt;&lt;\/asp:CustomValidator&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;asp:Button ID=&#8221;Button1&#8243; runat=&#8221;server&#8221; Text=&#8221;Button&#8221; \/&gt; In aspx.cs &nbsp; [&hellip;]<\/p>\n","protected":false},"author":43,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"categories":[23],"tags":[],"class_list":["post-112","post","type-post","status-publish","format-standard","hentry","category-asp-net"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Himanshu Namdeo","author_link":"https:\/\/debuggersspace.com\/author\/admin\/"},"uagb_comment_info":0,"uagb_excerpt":"Example for Custom validator In&nbsp;Designer&nbsp;aspx &nbsp; &lt;asp:TextBox ID=&#8221;TextBox1&#8243; runat=&#8221;server&#8221;&gt;&lt;\/asp:TextBox&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&lt;asp:CustomValidator ID=&#8221;CustomValidator1&#8243; runat=&#8221;server&#8221;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ErrorMessage=&#8221;Not a even no&#8221; ControlToValidate=&#8221;TextBox1&#8243;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ForeColor =&#8221;Red&#8221; onservervalidate=&#8221;CustomValidator1_ServerValidate&#8221; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &gt;&lt;\/asp:CustomValidator&gt; &nbsp; &nbsp; &nbsp; &nbsp; &lt;asp:Button ID=&#8221;Button1&#8243; runat=&#8221;server&#8221; Text=&#8221;Button&#8221; \/&gt; In aspx.cs &nbsp;&hellip;","_links":{"self":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/112"}],"collection":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/comments?post=112"}],"version-history":[{"count":0,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/posts\/112\/revisions"}],"wp:attachment":[{"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/media?parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/categories?post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/debuggersspace.com\/index.php\/wp-json\/wp\/v2\/tags?post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}