tags:

views:

68

answers:

1

Hello,

I have an ASP.NET application that has a DIV and an IFRAME. The DIV hosts my Silverlight application. The IFRAME points to another page on my site. When a user clicks a button in my Silverlight application, I'm trying to set a value in a hidden field on the page in the IFRAME and submit the page.

Currently, I'm calling a JavaScript function in the page that hosts my Silverlight application. I'm trying to use the JavaScript function to then interact with the page in the IFRAME through the HTML DOM. Oddly, whenever I access the document element on the FRAME object, a message is passed back to my Silverlight application that says:

"Type 'slBridge' does not exist. Parameter name: typeName"

Here is the code calling the JavaScript function in my Silverlight application.

HtmlPage.Window.CreateInstance("slBridge", new string[] { });

Here is my JavaScript code:

  function slBridge() {
    alert("Getting to execute JS");
      for (i = 0; i < window.frames.length; i++) {
        if (window.frames[i].name == "bridgeIFrame") {
        alert(windows.frames[i].document.title);      // If I remove this line it works. I can print the value of "i" as well
        break;
      }
    }                                
  }     

Is there some security thing that I am not aware of? If so, how do I access an IFrame from my SL application?

Thank you

A: 

I'm not sure why you are using CreateInstance. To invoke a function use Invoke:-

 HtmlPage.Window.Invoke("slBridge");
AnthonyWJones
I tried this approach as well. However, I still run into the same problem. Is there a security restriction?
There will only be a security restriction if the silverlight XAP is being pulled from a different site to that of the page that is hosting it.
AnthonyWJones