Skip to main content

Microsoft Silverlight

Answered Question how to access the codebehind function in javascriptRSS Feed

(0)

bobbby
bobbby

Member

Member

53 points

173 Posts

how to access the codebehind function in javascript

var slhost = document.getElementById("Xaml1"); slhost.content.SilverlightLearn.GetDoubleValue();----here unknown exception is coming

 

i given this in code behind

void Page_Loaded(object sender, RoutedEventArgs e)

{

HtmlPage.RegisterScriptableObject("SilverlightLearn", this);

}

[ScriptableMember]
public void GetDoubleValue()

{

// return a double

user.Username = "kk:";

// return (double)42;

}

 

 id name  Xaml1 also i given correctly

i don't know why unknown exception is coming

how to solve that

Bobby

ssenthil
ssenthil

Member

Member

501 points

108 Posts

Re: how to access the codebehind function in javascript

From where you are calling that javascript function

check any errors in javascript function

 

Mog Liang - MSFT
Mog Lian...

All-Star

All-Star

15884 points

1,541 Posts

Answered Question

Re: how to access the codebehind function in javascript

Hi,

bobbby:

var slhost = document.getElementById("Xaml1"); slhost.content.SilverlightLearn.GetDoubleValue();----here unknown exception is coming

This is not right way to invoke method. Please follow this article

 Walkthrough: Calling Managed Code from JavaScript

Thanks,

 

Mog Liang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities