Enable DOM Access for Silverlight Web Part in Sharepoint 2010

Posted by Bhaskar on Stack Overflow See other posts from Stack Overflow or by Bhaskar
Published on 2010-05-18T11:00:15Z Indexed on 2010/05/18 11:10 UTC
Read the original article Hit count: 671

I am hosting a silverlight 3.0 control on my Sharepoint 2010 page. I am using the built-in SilverlightWebPart web part, where I have provided the path for .xap file.

Its displaying properly, but when I try to access the System.Windows.Browser, its throwing an error. My code is:

public static string GetQueryString(string key)
        {
            try
            {
                var documentQueryString = (Dictionary<string, string>)System.Windows.Browser.HtmlPage.Document.QueryString;
                if (documentQueryString.ContainsKey(key))
                {
                    return documentQueryString[key].ToString();
                }
            }
            catch (Exception ex)
            {
                return ex.Message;
            }
            return string.Empty;
        }

The error I am getting is: The DOM/scripting bridge is disabled. How do I enable this? I know if I host this in a ASP.NET page, I can add the param - <param name="enablehtmlaccess" value="true"/>. I have tried putting this webpart in a "content editor web part", and I have embedded the object tag to call the .xap file and its working totally fine. I need to make it work using the built-in Silverlight web part.

© Stack Overflow or respective owner

Related posts about sharepoint2010

Related posts about silverlight-3.0