views:

585

answers:

2

Background: I have a Silverlight Control in a sharepoint webpart that exposes some scriptable methods. I use those methods to call a webservice and get an array of menu options. These menu options are then injected into Sharepoint ECB menu which appears on clicking an item in a list.

The problem I am having is being able to get the clientID of the silverlight control in Javascript so then I can use it to call the scriptable method. The page this will be on may have multiple instances of the same silverlight control as well as the controls hierarchy might be different....

Here's the client side JS code I currently have in which the clientID is hardcoded...

function TestQueryMenu() {
        var plugin = document.getElementById('ctl02_IntuitionModelBrowserControl');
        var contextUri = document.getElementById('TestUri').value;
        var key = contextUri;
        plugin.Content.ModelBrowser.GetContextMenuOptionsCompleted = MenuItemsReceived;
        plugin.Content.ModelBrowser.GetContextMenuOptionsAsync(key, contextUri);
    }
A: 

I ended up injecting the PLugin ID from the codebehind onto the page as a hiddenfield using the following function...

Page.ClientScript.RegisterHiddenField().

I then used javascript to read value of the hiddenfield.

Abdullah Ahmed
A: 

Hi,

I think the blog post "Passing Parameters Into Silverlight Applications" form Mr. Jesse "Silverlight" Liberty could help you solving your problem.

Flo
That was a very informative link Flo. But that explains how to get parameters into Silverlight. As I explained in my answer I managed to inject the plugin ID into a hidden field and then used javascript to get the value.Thanks :)
Abdullah Ahmed
Oh sorry, I miss understood your problem.
Flo