Sharepoint Web 部件中 Silverlight 控件的客户端 ID
背景:我在共享点 Web 部件中有一个 Silverlight 控件,它公开了一些可编写脚本的方法。 我使用这些方法来调用 Web 服务并获取一系列菜单选项。 然后,这些菜单选项将被注入到 Sharepoint ECB 菜单中,该菜单在单击列表中的某个项目时出现。
我遇到的问题是能够在 Javascript 中获取 silverlight 控件的 clientID,这样我就可以使用它来调用可编写脚本的方法。 该页面可能有相同 silverlight 控件的多个实例,并且控件层次结构可能不同...
这是我当前拥有的客户端 JS 代码,其中 clientID 是硬编码的...
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);
}
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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我最终使用以下函数将 PLugin ID 从代码隐藏注入到页面上作为隐藏字段...
Page.ClientScript.RegisterHiddenField()。
然后我使用 javascript 读取隐藏字段的值。
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.
我认为博客文章“将参数传递到 Silverlight 应用程序” 来自 Jesse "Silverlight" 先生的 Liberty 可以帮助您解决您的问题。
I think the blog post "Passing Parameters Into Silverlight Applications" form Mr. Jesse "Silverlight" Liberty could help you solving your problem.