{"id":591,"date":"2016-10-05T09:12:45","date_gmt":"2016-10-05T09:12:45","guid":{"rendered":"http:\/\/blog.softreeconsulting.com\/?p=591"},"modified":"2016-10-05T09:12:45","modified_gmt":"2016-10-05T09:12:45","slug":"asp-net-validators-sharepoint","status":"publish","type":"post","link":"https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/","title":{"rendered":"ASP.Net Validators in SharePoint"},"content":{"rendered":"<p><a href=\"http:\/\/blog.softreeconsulting.com\/wp-content\/uploads\/2016\/10\/COMMANDS1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-592\" src=\"https:\/\/blog.softreeconsulting.com\/wp-content\/uploads\/2016\/10\/COMMANDS1.png\" alt=\"commands1\" width=\"935\" height=\"513\" \/><\/a><\/p>\n<p>There are times when emerge the requirements of adding various client side validations on the web pages. Perquisite is there is an easy way to do this in ASP.Net by the utilizing the existing set of validator controls.<\/p>\n<p>When we design custom webparts in SharePoint, not to mention it takes some data as input, in that way we have to Asp.Net to add some client side validation. However, there are few things that you ought to keep in mind while using Asp.Net validator controls in the on board with SharePoint.<\/p>\n<ul>\n<li>There may be more than one control you will find, that trigger server side postbacks. If this is the case the validator controls will validate individually with each postback. However, the requirement may vary some times and you might have validate the form with single postback event, for instance through the \u201cSUBMIT\u201d button. In order to steer clear of this situation, you must put \u201cCauses Validation property\u201d to false. You need to do the same for all the controls causing server side postbacks OR for all those postbacks for which you do not want the form to get validated. (e.g.CausesValidation=&#8221;false&#8221;)<\/li>\n<li>As mentioned in our previous <a href=\"http:\/\/blog.softreeconsulting.com\/office-365\/how-to-modify-search-results-search-core-result-web-part-sharepoint\/\">article<\/a> , SharePoint page facilitates multiple webparts. Therefore, if the one of the webparts is being integrated with ASP.Net validator, it will always create issues with the postback events along with the page that contains other webparts. To steer clear of this issue and confine the validation to a particular webpart, you have to use ValidationGroupProperty within a specific webpart with a unique name.<\/li>\n<\/ul>\n<p>e.g. ValidationGroup=&#8221;UniqueGroupName&#8221;<\/p>\n<ul>\n<li>If you are following all the above facts and thinking everything is done then stop&#8230; there is still a problem which needs to be sorted out in SharePoint. When there is ASP.Net validator integrated within a webpart, webpart properties wouldn\u2019t allow you to save the changes due to the validators, no matter if the with ValidationGroups set. To fix this go to the webpart and find Form Mode within the Page Load event then disable the ASP.Net validator controls while the form is in \u201cNEW\u201dor \u201cEDIT\u201d mode.<\/li>\n<\/ul>\n<p>e.g.<\/p>\n<p>* If SPContext.Current.FormContext.FormMode = SPControlMode.Edit<\/p>\n<p>* Or SPContext.Current.FormContext.FormMode = SPControlMode.New Then<\/p>\n<p>* &#8216;Set the visibility of the required field control to False<\/p>\n<p>* End If<\/p>\n<p><a href=\"http:\/\/softreeconsulting.com\/\"><em>Softree Consulting <\/em><\/a><em>employs SharePoint consultants, who are experienced in writing for a multiplicity of SharePoint verticals including technical, promotional, creative, branding content, cataloguing and ethical media comprising journalism.<\/em><\/p>\n<p><em>With more than 10 years of industry experience these professionals have the best resources to deliver optimum results. They have been satisfying customers with some of the best SharePoint Strategies. In case you need experts for <\/em><a href=\"http:\/\/www.softreeconsulting.com\/offshore-sharepoint-developers\/\"><em>Offshore development for SharePoint 2016<\/em><\/a><em>, we have got you covered.<\/em><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are times when emerge the requirements of adding various client side validations on the web pages. Perquisite is there is an easy way to do this in ASP.Net by the utilizing the existing set of validator controls. When we design custom webparts in SharePoint, not to mention it takes some data as input, in that way we have to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":592,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43],"tags":[],"class_list":["post-591","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sharepoint"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>ASP.Net Validators in SharePoint - Softree Technology<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ASP.Net Validators in SharePoint - Softree Technology\" \/>\n<meta property=\"og:description\" content=\"There are times when emerge the requirements of adding various client side validations on the web pages. Perquisite is there is an easy way to do this in ASP.Net by the utilizing the existing set of validator controls. When we design custom webparts in SharePoint, not to mention it takes some data as input, in that way we have to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/\" \/>\n<meta property=\"og:site_name\" content=\"Softree Technology\" \/>\n<meta property=\"article:published_time\" content=\"2016-10-05T09:12:45+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ASP.Net Validators in SharePoint - Softree Technology","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/","og_locale":"en_US","og_type":"article","og_title":"ASP.Net Validators in SharePoint - Softree Technology","og_description":"There are times when emerge the requirements of adding various client side validations on the web pages. Perquisite is there is an easy way to do this in ASP.Net by the utilizing the existing set of validator controls. When we design custom webparts in SharePoint, not to mention it takes some data as input, in that way we have to [&hellip;]","og_url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/","og_site_name":"Softree Technology","article_published_time":"2016-10-05T09:12:45+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/#article","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/"},"author":{"name":"admin","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b"},"headline":"ASP.Net Validators in SharePoint","datePublished":"2016-10-05T09:12:45+00:00","mainEntityOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/"},"wordCount":467,"commentCount":0,"publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/#primaryimage"},"thumbnailUrl":"","articleSection":["SharePoint"],"inLanguage":"en","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/","url":"https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/","name":"ASP.Net Validators in SharePoint - Softree Technology","isPartOf":{"@id":"https:\/\/softreetechnology.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/#primaryimage"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/#primaryimage"},"thumbnailUrl":"","datePublished":"2016-10-05T09:12:45+00:00","breadcrumb":{"@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/#breadcrumb"},"inLanguage":"en","potentialAction":[{"@type":"ReadAction","target":["https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/"]}]},{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/#primaryimage","url":"","contentUrl":""},{"@type":"BreadcrumbList","@id":"https:\/\/softreetechnology.com\/blog\/sharepoint\/asp-net-validators-sharepoint\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/softreetechnology.com\/blog\/"},{"@type":"ListItem","position":2,"name":"ASP.Net Validators in SharePoint"}]},{"@type":"WebSite","@id":"https:\/\/softreetechnology.com\/blog\/#website","url":"https:\/\/softreetechnology.com\/blog\/","name":"Softree Technology","description":"Celebrating 10+ Years in SharePoint Consulting !","publisher":{"@id":"https:\/\/softreetechnology.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/softreetechnology.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en"},{"@type":"Organization","@id":"https:\/\/softreetechnology.com\/blog\/#organization","name":"Softree Technology","url":"https:\/\/softreetechnology.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","contentUrl":"https:\/\/softreetechnology.com\/blog\/wp-content\/uploads\/2023\/03\/cropped-white-logo-soft.png","width":844,"height":230,"caption":"Softree Technology"},"image":{"@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/98740297642f06debccdcee2de84086b","name":"admin","image":{"@type":"ImageObject","inLanguage":"en","@id":"https:\/\/softreetechnology.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6fc78c8a7aa3fb0bf43c3b9a2e3962d7?s=96&d=mm&r=g","caption":"admin"},"sameAs":["https:\/\/softreeconsulting.com"],"url":"https:\/\/softreetechnology.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/591","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/comments?post=591"}],"version-history":[{"count":0,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/posts\/591\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/media?parent=591"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/categories?post=591"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/softreetechnology.com\/blog\/wp-json\/wp\/v2\/tags?post=591"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}