// in SL code behind - ScriptObject js = (ScriptObject)HtmlPage.Window.GetProperty("some_js_function"); js.InvokeSelf("called from SL"); //Javascript in page - function some_js_function(arg) { alert(arg.toString()); }
// JS function in the page, called by a button's onclick function Call_SL_Method(arg) { var sl = document.getElementById("silverlightControl"); sl.content.Page.SetUserName(arg); } //in Silverlight Code Behind, decorate the class & method to expose to JS [ScriptableType()] public partial class MainPage : UserControl { [ScriptableMember()] public void SetUserName(string name) { //txtName is a textblock to hold user name txtName.Text = name; } public MainPage() { InitializeComponent(); //register the class with the HtmlPage HtmlPage.RegisterScriptableObject("Page", this); .... }
Přihlášení členové mohou přispívat, sledovat aktualizace a další. Jste tu noví? Zaregistrujte si bezplatný účet.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.