// 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); .... }
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.