{"id":63,"date":"2015-11-05T03:10:00","date_gmt":"2015-11-05T03:10:00","guid":{"rendered":"http:\/\/waynenguyen.org\/dev\/2015\/11\/05\/allow-aspnet-form-to-be-used-after\/"},"modified":"2016-05-21T03:15:53","modified_gmt":"2016-05-21T03:15:53","slug":"allow-aspnet-form-to-be-used-after","status":"publish","type":"post","link":"https:\/\/bruceng.com\/dev\/?p=63","title":{"rendered":"Allow ASP.NET form to be used after downloading a file in SharePoint webpart"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\">\nSolution: the most effective solution: add &#8220;_spFormOnSubmitCalled=false;_spSuppressFormOnSubmitWrapper=true;&#8221; to OnClientClick of the button<\/p>\n<div class=\"MsoNormal\">\n<\/div>\n<div class=\"MsoNormal\">\n&lt;asp:LinkButton ID=&#8221;lbExport&#8221;<br \/>\nrunat=&#8221;server&#8221; Text=&#8221;Export&#8221;<br \/>\nOnClick=&#8221;lbExport_Click&#8221;<br \/>\nOnClientClick=&#8221;_spFormOnSubmitCalled=false;_spSuppressFormOnSubmitWrapper=true;&#8221;\/&gt;<\/div>\n<p>Solution:<\/p>\n<p>Add this code to the .ascx file<\/p>\n<p>&lt;script type=&#8221;text\/javascript&#8221;&gt;<br \/>\n&nbsp; &nbsp; function setFormSubmitToFalse() {<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; setTimeout(function () { _spFormOnSubmitCalled = false; }, 3000);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; return true;<br \/>\n&nbsp; &nbsp; }<br \/>\n&lt;\/script&gt;<\/p>\n<p>Then, for the download button, add the code to call this function after user clicks it<\/p>\n<p>OnClientClick=&#8221;setFormSubmitToFalse&#8221;<\/p>\n<p>Another way is to refresh the page on client after certain time<\/p>\n<div class=\"post-text\" itemprop=\"text\" style=\"background-color: white; border: 0px; color: #222222; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 15px; line-height: 1.3; margin: 0px 0px 5px; padding: 0px; width: 660px; word-wrap: break-word;\">\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;\">onclientclick=\"timedRefresh(2000)\"\n\nthen in your html..\n\n    &lt;script type=\"text\/JavaScript\"&gt;\n    &lt;!--\n    function timedRefresh(timeoutPeriod) {\n        setTimeout(\"location.reload(true);\",timeoutPeriod);\n    }\n    \/\/   --&gt;<\/pre>\n<div>\n<\/div>\n<div style=\"border: 0px; clear: both; margin-bottom: 1em; padding: 0px;\">\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Solution: the most effective solution: add &#8220;_spFormOnSubmitCalled=false;_spSuppressFormOnSubmitWrapper=true;&#8221; to OnClientClick of the button &lt;asp:LinkButton ID=&#8221;lbExport&#8221; runat=&#8221;server&#8221; Text=&#8221;Export&#8221; OnClick=&#8221;lbExport_Click&#8221; OnClientClick=&#8221;_spFormOnSubmitCalled=false;_spSuppressFormOnSubmitWrapper=true;&#8221;\/&gt; Solution: Add this code to the .ascx file &lt;script type=&#8221;text\/javascript&#8221;&gt; &nbsp; &nbsp; function setFormSubmitToFalse() { &nbsp; &nbsp; &nbsp; &nbsp; setTimeout(function () { _spFormOnSubmitCalled = false; }, 3000); &nbsp; &nbsp; &nbsp; &nbsp; return true; &nbsp; &nbsp; } &lt;\/script&gt; &hellip; <a href=\"https:\/\/bruceng.com\/dev\/?p=63\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Allow ASP.NET form to be used after downloading a file in SharePoint webpart&#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":[2,17,16,15],"class_list":["post-63","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-asp-net","tag-debug","tag-issues","tag-sharepoint"],"_links":{"self":[{"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/posts\/63","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=63"}],"version-history":[{"count":1,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/posts\/63\/revisions"}],"predecessor-version":[{"id":183,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=\/wp\/v2\/posts\/63\/revisions\/183"}],"wp:attachment":[{"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=63"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=63"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bruceng.com\/dev\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=63"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}