{"id":70299,"date":"2021-09-01T04:10:04","date_gmt":"2021-09-01T08:10:04","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/asp-net-validation-control-examples-in-c-net-web-applications\/"},"modified":"2025-05-11T20:17:27","modified_gmt":"2025-05-11T20:17:27","slug":"asp-net-validation-control-examples-in-c-net-web-applications","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=70299","title":{"rendered":"ASP.Net Validation Control Examples in C# #.Net Web Applications"},"content":{"rendered":"<p>Brought from: http:\/\/salearningschool.com\/displayArticle.php?table=Articles&amp;articleID=1325&amp;title=ASP.Net%20Validation%20Control%20Examples%20in%20C#.<\/p>\n<p>  ASP.Net Validation Control Examples. Just check the code below<\/p>\n<p>Some notes<\/p>\n<ul>\n<li> RequiredFieldValidator: is used to check that a field is filled up<\/li>\n<li> CompareValidator: Compare the value of a field with another field or data<\/li>\n<li> RangeValidator: Compares the data is within a given range<\/li>\n<li> RegularExpressionValidator: Domain name syntax, email addtress syntax<\/li>\n<li> ValidationSummary: Display all validation errors in a summary box<\/li>\n<li> CompareValidator: Write your own custom validation rules and display the outcome<\/li>\n<li> Remember\n<ul>\n<li> You can display error on the side of the control<\/li>\n<li> You can display error under the control<\/li>\n<li> The example used both just for example<\/li>\n<li> The Text property is the output that comes just where the validation control is placed. ErrorMessage propert is for the ValidationSummary\n     <\/li>\n<li> If you just want the Validation Summary output, use Display=&#8221;none&#8221; for the validation control (not the summarycontrol) itself\n    <\/li>\n<\/ul>\n<\/li>\n<li> the code can be seen at http:\/\/salearningschool.com\/samples\/validate.txt as well<\/li>\n<\/ul>\n<pre style=\"padding:10px;font-size:12px\">&lt;%@ Page Language=\"C#\" AutoEventWireup=\"true\" CodeFile=\"validation.aspx.cs\" \nInherits=\"validation\" %&gt;\n\n&lt;!DOCTYPE html&gt;\n\n&lt;html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"&gt;\n&lt;head runat=\"server\"&gt;\n    &lt;title&gt;Validation Control&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;   \n\n\n    &lt;form id=\"form1\" runat=\"server\"&gt;\n    &lt;div&gt;\n\n\n        &lt;asp:ValidationSummary ID=\"ValidationSummary1\"\n            HeaderText=\"Form Validation Summary\"\n            DisplayMode=\"BulletList\"\n            EnableClientScript=\"true\"\n             ForeColor = \"Red\"\n            runat=\"server\"\n        \/&gt;\n\n        &lt;asp:Label ID=\"lblFirstName\" runat=\"server\" Text=\"First Name:\" \n        Width=\"120\"&gt;&lt;\/asp:Label&gt;\n        &lt;asp:TextBox ID=\"txtFirstName\" runat=\"server\"&gt;&lt;\/asp:TextBox&gt;\n\n        &lt;asp:RequiredFieldValidator ID=\"firstNameValidator\"\n             ControlToValidate=\"txtFirstName\"\n             ErrorMessage=\"First Name Required\"\n             InitialValue=\"\"\n             Text=\"\"\n             Display =\"None\"\n             runat=\"server\"\/&gt;\n\n        &lt;br \/&gt;\n\n        &lt;asp:Label ID=\"lblLastName\" runat=\"server\" Text=\"Last Name\" Width=\"120\"&gt;\n        &lt;\/asp:Label&gt;\n        &lt;asp:TextBox ID=\"txtLastName\" runat=\"server\"&gt;&lt;\/asp:TextBox&gt;\n        &lt;br\/&gt;\n        &lt;asp:RequiredFieldValidator ID=\"RequiredFieldValidator1\"\n             ControlToValidate=\"txtLastName\"\n             ErrorMessage=\"Last Name Required\"\n             InitialValue=\"\"\n             Text=\"Last Name Required\"            \n             ForeColor=\"Red\"\n             runat=\"server\"\/&gt;\n\n         &lt;br \/&gt;\n\n        &lt;asp:Label ID=\"lblEmail\" runat=\"server\" Text=\"Email:\" Width=\"120\"&gt;\n        &lt;\/asp:Label&gt;\n        &lt;asp:TextBox ID=\"txtEmail\" runat=\"server\"&gt;&lt;\/asp:TextBox&gt;\n\n        &lt;asp:RegularExpressionValidator ID=\"emailValidation\" \n            runat=\"server\" \n            ControlToValidate=\"txtEmail\" \n            ErrorMessage=\"Invalid Fformat\"              \n            ValidationExpression=\"^([a-zA-Z][w.-]*[a-zA-Z0-9]@[a-zA-Z0-9][w.-]*[a-zA-Z0-9]\n            .[a-zA-Z][a-zA-Z.]*[a-zA-Z]){1,70}$\"\n            ForeColor =\"Red\"            \n         \/&gt;\n             \n        &lt;br \/&gt;\n\n        &lt;asp:Label ID=\"lblPassword\" runat=\"server\" Text=\"Password\" Width=\"120\"&gt;\n        &lt;\/asp:Label&gt;\n        &lt;asp:TextBox ID=\"txtPassword\" runat=\"server\" TextMode=\"Password\"&gt;\n        &lt;\/asp:TextBox&gt;\n        &lt;br \/&gt;\n\n        &lt;asp:Label ID=\"lblPassword2\" runat=\"server\" Text=\"Re Enter Password\" Width=\"120\"&gt;\n        &lt;\/asp:Label&gt;\n        &lt;asp:TextBox ID=\"txtPassword2\" runat=\"server\" TextMode=\"Password\"&gt;\n        &lt;\/asp:TextBox&gt;\n        &lt;br \/&gt;\n\n         &lt;asp:CompareValidator ID=\"compareV\" ControlToValidate=\"txtPassword\" \n         ControlToCompare=\"txtPassword2\" runat=\"server\" Text=\"mismatchmatch\" \n         ForeColor=\"Red\" \/&gt;\n\n        &lt;br \/&gt;\n\n        &lt;asp:Button ID=\"btnSubmit\" runat=\"server\" OnClick=\"Button1_Click\" Text=\"Submit\" \/&gt;\n\n    &lt;\/div&gt;        \n    &lt;\/form&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n<p>From: http:\/\/sitestree.com\/?p=3729<br \/> Categories:.Net Web Applications<br \/>Tags:<br \/> Post Data:2016-07-16 11:12:48<\/p>\n<pre><code>    Shop Online: &lt;a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\"&gt;https:\/\/www.ShopForSoul.com\/&lt;\/a&gt;\n    (Big Data, Cloud, Security, Machine Learning): Courses: &lt;a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"&gt; http:\/\/Training.SitesTree.com&lt;\/a&gt; \n    In Bengali: &lt;a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\"&gt;http:\/\/Bangla.SaLearningSchool.com&lt;\/a&gt;\n    &lt;a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\"&gt;http:\/\/SitesTree.com&lt;\/a&gt;\n    8112223 Canada Inc.\/JustEtc: &lt;a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\"&gt;http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) &lt;\/a&gt;\n    Shop Online: &lt;a href='https:\/\/www.ShopForSoul.com'&gt; https:\/\/www.ShopForSoul.com\/&lt;\/a&gt;\n    Medium: &lt;a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"&gt; https:\/\/medium.com\/@SayedAhmedCanada &lt;\/a&gt;\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Brought from: http:\/\/salearningschool.com\/displayArticle.php?table=Articles&amp;articleID=1325&amp;title=ASP.Net%20Validation%20Control%20Examples%20in%20C#. ASP.Net Validation Control Examples. Just check the code below Some notes RequiredFieldValidator: is used to check that a field is filled up CompareValidator: Compare the value of a field with another field or data RangeValidator: Compares the data is within a given range RegularExpressionValidator: Domain name syntax, email addtress syntax ValidationSummary: Display &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=70299\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1973,1917],"tags":[],"class_list":["post-70299","post","type-post","status-publish","format-standard","hentry","category-c-misc","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":69890,"url":"http:\/\/bangla.sitestree.com\/?p=69890","url_meta":{"origin":70299,"position":0},"title":"ASP.Net Validation Control Examples in C#. #19","author":"Author-Check- Article-or-Video","date":"August 21, 2021","format":false,"excerpt":"ASP.Net Validation Control Examples. Just check the code below Some note RequiredFieldValidator: is used to check that a field is filled up CompareValidator: Compare the value of a field with another field or data RangeValidator: Compares the data is within a given range RegularExpressionValidator: Domain name syntax, email addtress syntax\u2026","rel":"","context":"In &quot;C# - Misc&quot;","block_context":{"text":"C# - Misc","link":"http:\/\/bangla.sitestree.com\/?cat=1973"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":69860,"url":"http:\/\/bangla.sitestree.com\/?p=69860","url_meta":{"origin":70299,"position":1},"title":"ASP.Net Examples #19","author":"Author-Check- Article-or-Video","date":"August 21, 2021","format":false,"excerpt":"ASP.NET HTML Controls HTMLAnchorHTMLButtonHTMLImageHTMLImage 2HTMLInputbuttonHTMLInputCheckboxHTMLInputHiddenHTMLInputImageHTMLInputRadiobuttonHTMLTableHTMLTable 2HTMLTextarea ASP.NET Web Controls AdRotatorButtonButton 2CalendarCalendar 2Calendar 3CheckboxCheckboxListDataListDataList with stylesDataList with DropdownListHyperlinkImageImageButtonLabelLinkButtonListboxLiteralLiteral 2PanelRadiobuttonRadiobuttonListRepeaterRepeater with Repeater with TableTable 2TextboxTextbox 2Textbox 3XML ASP.NET Validation Controls CompareValidatorCompareValidator 2CustomValidatorRangeValidatorRangeValidator 2RegularExpressionValidatorRequiredFieldValidatorValidationsummaryValidationsummary 2 ASP.NET Events Page_LoadPage.IsPostBack ASP.NET Data Binding ArrayList RadioButtonListArrayList DropDownListHashtable RadioButtonList 1Hashtable RadiobuttonList 2Hashtable DropDownListSortedList RadioButtonList 1SortedList RadiobuttonList 2SortedList\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":6473,"url":"http:\/\/bangla.sitestree.com\/?p=6473","url_meta":{"origin":70299,"position":2},"title":"ASP.NET \u099f\u09bf\u0989\u099f\u09cb\u09b0\u09bf\u09df\u09be\u09b2 :[\u09aa\u09b0\u09cd\u09ac\u0983 \u09e8\u09e8]:: ASP.NET Web Forms \u098f\u09b0 Validation Server Controls \u099f\u09cd\u09af\u09be\u0997\u09c7\u09b0 \u09ac\u09b0\u09cd\u09a3\u09a8\u09be","author":"Author-Check- Article-or-Video","date":"February 21, 2015","format":false,"excerpt":"ASP.NET \u099f\u09bf\u0989\u099f\u09cb\u09b0\u09bf\u09df\u09be\u09b2 :[\u09aa\u09b0\u09cd\u09ac\u0983 \u09e8\u09e8]:: ASP.NET Web Forms \u098f\u09b0 Validation Server Controls \u099f\u09cd\u09af\u09be\u0997\u09c7\u09b0 \u09ac\u09b0\u09cd\u09a3\u09a8\u09be \u09b2\u09c7\u0996\u0995\u0983 \u09ae\u09cb\u09b8\u09cd\u09a4\u09be\u09ab\u09bf\u099c\u09c1\u09b0 \u09ab\u09bf\u09b0\u09cb\u099c \u0964 \u0995\u09c7\u09ae\u09a8 \u09b6\u09bf\u0996\u09b2\u09c7\u09a8 ASP.NET ? \u09b6\u09bf\u0996\u09a4\u09c7 \u09b6\u09bf\u0996\u09a4\u09c7 ASP.NET \u098f\u09b0 \u09b8\u09ac\u0987 \u09b6\u09bf\u0996\u09c7 \u09ab\u09c7\u09b2\u09b2\u09be\u09ae \u0964 \u0986\u099c \u0986\u09ae\u09b0\u09be ASP.NET \u098f\u09b0 \u09b6\u09c7\u09b7 \u09aa\u09b0\u09cd\u09ac\u09c7 \u09aa\u09cc\u099b\u09c7 \u0997\u09c7\u099b\u09bf \u0964 \u09a4\u09be\u0987 \u0986\u099c ASP.NET Web Forms \u098f\u09b0 Validation Server Controls \u099f\u09cd\u09af\u09be\u0997\u09c7\u09b0 \u09ac\u09b0\u09cd\u09a3\u09a8\u09be \u09b6\u09bf\u0996\u09b2\u09c7\u0987\u2026","rel":"","context":"In &quot;Root&quot;","block_context":{"text":"Root","link":"http:\/\/bangla.sitestree.com\/?cat=1"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":70265,"url":"http:\/\/bangla.sitestree.com\/?p=70265","url_meta":{"origin":70299,"position":3},"title":"ASP.Net Controls #.Net Web Applications","author":"Author-Check- Article-or-Video","date":"August 30, 2021","format":false,"excerpt":"Brought from: http:\/\/salearningschool.com\/displayArticle.php?table=Articles&articleID=746&title=ASP.Net%20Controls \u00a0 HTML Server Controls HtmlAnchor HtmlButton HtmlForm HtmlGeneric HtmlImage HtmlInputButton HtmlInputCheckBox HtmlInputFile HtmlInputHidden HtmlInputImage HtmlInputRadioButton HtmlInputText HtmlSelect HtmlTable HtmlTableCell HtmlTableRow HtmlTextArea Web Server Controls AdRotator Button Calendar CalendarDay CheckBox CheckBoxList DataGrid DataList DropDownList HyperLink Image ImageButton Label LinkButton ListBox ListItem Literal Panel PlaceHolder RadioButton RadioButtonList BulletedList Repeater\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":70263,"url":"http:\/\/bangla.sitestree.com\/?p=70263","url_meta":{"origin":70299,"position":4},"title":"ASP.Net Controls #.Net Web Applications","author":"Author-Check- Article-or-Video","date":"August 30, 2021","format":false,"excerpt":"HTML Server Controls HtmlAnchor HtmlButton HtmlForm HtmlGeneric<br\/> HtmlImage HtmlInputButton HtmlInputCheckBox HtmlInputFile HtmlInputHidden HtmlInputImage HtmlInputRadioButton HtmlInputText HtmlSelect HtmlTable HtmlTableCell HtmlTableRow HtmlTextArea Web Server Controls AdRotator Button Calendar CalendarDay CheckBox CheckBoxList DataGrid DataList DropDownList HyperLink Image ImageButton Label LinkButton ListBox ListItem Literal Panel PlaceHolder RadioButton RadioButtonList BulletedList Repeater Style Table TableCell TableRow\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":78364,"url":"http:\/\/bangla.sitestree.com\/?p=78364","url_meta":{"origin":70299,"position":5},"title":"Query Strings in C#","author":"Sayed","date":"August 5, 2025","format":false,"excerpt":"Here\u2019s a complete, copyright-free guide to Query Strings in C# \/ ASP.NET, including definition, examples, use cases, limitations, performance, and security. You can freely copy-paste this on your blog or Facebook page. \ud83d\udd17 Query String in C# ASP.NET \u2013 Complete Guide \ud83d\udcd8 Definition A query string is a part of\u2026","rel":"","context":"In &quot;C# - Misc&quot;","block_context":{"text":"C# - Misc","link":"http:\/\/bangla.sitestree.com\/?cat=1973"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/70299","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=70299"}],"version-history":[{"count":1,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/70299\/revisions"}],"predecessor-version":[{"id":78117,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/70299\/revisions\/78117"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=70299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=70299"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=70299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}