Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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