0

So I have a Silverlight control that I've added to an ASP.NET Web Forms page using the ActiveX object notation like so:

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="500" height="48">
    <param name="source" value="/ClientBin/FileUpload.xap?t=<%=DateTime.Now.ToUniversalTime() %>"/>
    <param name="onError" value="onSilverlightError" />
    <param name="background" value="white" />
    <param name="minRuntimeVersion" value="3.0.40818.0" />
    <param name="autoUpgrade" value="true" />
    <asp:Literal ID="SilverlightInitParams" runat="server" />
    <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40818.0" style="text-decoration:none">
        <img src="https://go.microsoft.com/fwlink/?LinkId=161376" alt="Get Microsoft Silverlight" style="border-style:none"/>
    </a>
</object>

Within the control, there's a button. When the button is clicked, I'd like a JavaScript script to be called. To see if I can get it to work, it should call a JavaScript function that definitely does exist. However, nothing happens.

Here's what the Silverlight code looks like:

public partial class FileUploadControl : UserControl
{
    ...

    public FileUploadControl(IDictionary<string,string> parameters)
    {
        ...
        HtmlPage.RegisterScriptableObject("Page", this);

        InitializeComponent();
    }

    private void chooseFileButton_Click(object sender, RoutedEventArgs e)
    {
        HtmlPage.Window.Invoke("showStatus");

        ...
    }

    ...
}

Here's the JavaScript method:

function showStatus() {
    alert('Test from Silverlight.');
}

Any ideas?

Jason N. Gaylord
  • 7,910
  • 15
  • 56
  • 95
  • Can you post the button code. I don't see the function being called in any of the code there. – PitaJ May 21 '12 at 20:45

1 Answers1

0

The .xap file was not copying to the deployment directory. I have another issue now, but I'm not quite sure what it is. I'm investigating that now.

Jason N. Gaylord
  • 7,910
  • 15
  • 56
  • 95