silverlight with javascript
when i m trying to invoke javascript function which is present in my default.aspx page, it is showing some error --> Failed to Invoke: TalkToJavaScript.
coding in my silverlight page is--
public MainPage()
{
InitializeComponent();
HtmlP开发者_如何学运维age.RegisterScriptableObject("Page", this);
HtmlPage.Window.Invoke("TalkToJavaScript", "Hello from Silverlight");
}
[ScriptableMember]
public void UpdateText(string result)
{
myTextbox.Text = result;
}
I would consider using this approach:-
public MainPage()
{
InitializeComponent();
HtmlPage.RegisterScriptableObject("Page", this);
Loaded += (s, args) => {
HtmlPage.Window.Invoke("TalkToJavaScript", "Hello from Silverlight");
};
}
I'm not sure why but I'd be uncomfortable calling back into Javascript from a constructor that I know is running in response to an Application_Startup. I'm either being irrational or this is the cause of your problem. Of course currently you aren't showing us the Javascript so you could simply have that messed up.
精彩评论