1

I am working on some mobile web parts and have got into a problem.

My issue is that I have a custom web part which is a mobile web part. I have got everything working and I can see the web part in the SharePoint mobile pages. I want to have an update panel in my web part and for that I added the scriptmanager on the user control web part.

Now when I see my web part on the page I get an error Object reference not set to an instance of an object. If I remove the update panel and script manager, everything is working fine as expected. So if someone can tell me how can I get script manager running in a SharePoint mobile page I would really appreciate it.

The page which SharePoint uses to display mobile web parts is mblwp.aspx and I guess there is no master page in mobile pages.

1 Answer 1

2

Try adding the following to the CreateChildControls override of your user control code-behind:

    if (System.Web.UI.ScriptManager.GetCurrent(this.Page) == null)
    {
        System.Web.UI.ScriptManager scriptMgr = new System.Web.UI.ScriptManager();
        this.Controls.AddAt(0, scriptMgr);
    }

...before base.CreateChildControls();

Should cause the script manager to be added correctly, but only if one is not already present. If that doesn't work, try:

this.Page.Form.Controls.Add(scriptMgr);

in place of:

this.Controls.AddAt(0, scriptMgr);

Hope that does the trick.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.