Add ScriptManager to Page Programmatically?

后端 未结 7 2138
夕颜
夕颜 2020-12-13 00:30

I am developing a WebPart (it will be used in a SharePoint environment, although it does not use the Object Model) that I want to expose AJAX functionality in. Because of t

7条回答
  •  天命终不由人
    2020-12-13 01:15

    This is the only way I could get my update panel to work in a sharepoint 2007 / 2010 compatible webpart. We use a 2010 master page with an scriptmanager but a 2007 master page without one.

    .ascx

    
    
    ...
    
    

    .ascx.cs

    public void updatePanel_Init(object sender, EventArgs e)
    {
        if (ScriptManager.GetCurrent(Page) == null)
        {
            ScriptManager sMgr = new ScriptManager();
            sMgr.EnablePartialRendering = true;
            sMgr_place.Controls.Add(sMgr);
        }
    }
    

提交回复
热议问题