开发者

silverlight with javascript

开发者 https://www.devze.com 2022-12-21 00:59 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消