{"id":118,"date":"2015-06-02T06:53:00","date_gmt":"2015-06-02T06:53:00","guid":{"rendered":"http:\/\/waynenguyen.org\/dev\/2015\/06\/02\/sharepoint-webpart-validation-prevents\/"},"modified":"2016-05-21T03:15:55","modified_gmt":"2016-05-21T03:15:55","slug":"sharepoint-webpart-validation-prevents","status":"publish","type":"post","link":"https:\/\/bruceng.com\/dev\/?p=118","title":{"rendered":"Sharepoint webpart validation prevents page from saving"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\">\nTo fix this problem. Check if there are validators preventing the page from saving, put in fake data to stop validation.<\/p>\n<p>When developing webparts, put in code to disable validators while in edit mode.<\/p>\n<pre class=\"default prettyprint prettyprinted\" style=\"background-color: #eeeeee; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; font-size: 13px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;\">\/\/if we are not in display mode disable all the validation controls to make sure saving the page the webpart is on works.\nif (SPWebPartManager.GetCurrentWebPartManager(Page).DisplayMode != WebPartManager.BrowseDisplayMode)\n{\n    foreach (var validator in Controls)\n    {\n        if (validator is BaseValidator)\n        {\n            ((BaseValidator)validator).Enabled = false;\n        }\n    }\n}<\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>To fix this problem. Check if there are validators preventing the page from saving, put in fake data to stop validation. When developing webparts, put in code to disable validators while in edit mode. \/\/if we are not in display mode disable all the validation controls to make sure saving the page the webpart is &hellip; <a href=\"https:\/\/bruceng.com\/dev\/?p=118\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Sharepoint webpart validation prevents page from saving&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-118","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/posts\/118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=118"}],"version-history":[{"count":1,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions"}],"predecessor-version":[{"id":238,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions\/238"}],"wp:attachment":[{"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}