TAGS :Viewed: 11 - Published at: a few seconds ago

[ Sharepoint "edit page" keeps loading due to certain webpart ]

I have a sharepoint test page. I inserted my webpart earlier before my development, but after a period of time now I find that when I click "edit page", the "loading" tag will run forever and I cannot edit my page.

Then I tried to type "?Contents=1" after my page url, delete the webpart and re-add it. When I tried to save my changes, the "saving" tag also runs forever.

Such issue only happens to my webpart. I tried to use other webparts and they works perfectly. Any one got some idea?

Answer 1


In your custom webpart code, you can understand if the page is in edit mode by the below code. Debug the code and try to understand the reasing of waiting. By this way, you can modify your webpart for edit mode.

 protected override void OnLoad(System.EventArgs e)
 {
 if (this.IsInEditMode)
        {

        }
 }    

private bool IsInEditMode
    {
        get
        {
            SPWebPartManager currentWebPartManager = (SPWebPartManager)WebPartManager.GetCurrentWebPartManager(this.Page);
            return (((currentWebPartManager != null) && !base.IsStandalone) && currentWebPartManager.GetDisplayMode().AllowPageDesign);
        }
    }

Answer 2


OK,I find the reason. Since my webpart has an textbox validator and by default the textbox is hidden, when I click "edit page", the validator will be fired and prevent the editing. I put the following code in my page_load JavaScript and the issue is solved.

$(function () {
    var rfv = document.getElementById("<%=rfvName.ClientID%>");
    ValidatorEnable(rfv, false);
});