Published

Silverlight Tips/Tricks: Communicating between Javascript and C#

This post is not an article. Just small notes that I made while I’m playing Silverlight. I attached all sample sourcecodes in this post. I hope you will find it useful. If you have some tips that you want to share with others, please let me know.

Tip #2. How to pass the parameters to Javascript function from C#

The default EventArgs class doesn’t have the parameters so that we have to create our own class which is inherited from EventArgs. Don’t forget to make it scriptable. Otherwise, it won’t work. (Thanks to Shawn Wildermuth who pointed me my mistake in this thread.)

I have been having some issues with Firefox 3. Silverlight will load and run ok but when I click a link that executes javascript code that calls a scriptible method, I get a javascript error that states that the “Control.Content” is undifined.

Everything works fine on IE, Safari, and even Chrome. The problem in firefox seems to be intermitant. It will work sometimes but fail other times. I may reload the browser then it will work. Sometimes it will not work no matter how many times I reload Firefox.

Hello Michael,
I am working on Silverlight 5.
I want to integrate javascript with silverlight.
The js functions or jquery must get embedded into my silverlight page,
For eg. If there is a animated banner it must be seen in my silverlight page along with my other controls.
The file which you have uploaded : CallJSFromCSharp.zip is not running.
Please upload it again or help me the steps to do the above.
Hope to get your reply soon..