// 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); .... }
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.