I faced a typical problem where I had to implement a tab control using AJAX in a sharepoint site. When I tested it in sharepoint, I found that only the first time click of the tab buttons was working. When I clicked for the first time in a tab button it was working but when I clicked the second time it wasn’t.

To solve this problem, I wrote a method which will reset the form action as there is a sharepoint script included for changing the form action which may stop the form submission.

//Fixing Form Action
        private void FixFormAction ()
        {
            if (this.Page.Form != null)
            {
                string formOnSubmitAtt = this.Page.Form.Attributes[“onsubmit”];
                if (formOnSubmitAtt == “return _spFormOnSubmitWrapper();”)
                {
                    this.Page.Form.Attributes[“onsubmit”] = “_spFormOnSubmitWrapper();”;
                }
            }
            ScriptManager.RegisterStartupScript(this, typeof(AjaxWebPart), “UpdatePanelFixup”, “_spOriginalFormAction = document.forms[0].action; _spSuppressFormOnSubmitWrapper=true;”, true);
        }

Or u can add the following after<@%Register> tag in your user contol
<script type=’text/javascript’>_spOriginalFormAction = document.forms[0].action; _spSuppressFormOnSubmitWrapper=true;</script>

which also does the same thing.

 

 

 

Advertisements