2010-11-18

Page.ParseControl with SharePoint Sandbox

There are many posts explaining that you cannot use visual web parts with the sharepoint sandbox. So this means you have to build your controls by hand, which is not that fun. Thinking I was smart, I tried to use the Page.LoadControl method to parse a string of controls. This way i could author the html easily.

Turns out though, that doesn't work. You get this error message in your webpart.






System.ArguementNullException: Value cannot be null. Parameter name: virtualPath at System.Web.VirtualPath.Create()

Which basically means that the process that executes the sandbox code is not a full ASP.NET pipeline, or doesn't have all the context/access object it needs. This is probably as security feature too.

Oh well, back to coding the control tree by hand.

1 comment:

Stephen Brown said...

You can set the AppRelativeVirtualPath of the Page object which allows the HTML to be parsed, but you get a further exception related to the operation requiring greater security permissions.