Add following C# code, where you want to call java script function.
HtmlPage.Window.Invoke("SayHello");
Add following java script code in aspx or html page in silver light web project.
function SayHello()
{
alert('Hello! function called from silverlight');
}
Java script function with parameters:
To call java script function with multiple input parameters, add following C# code in .cs file.
HtmlPage.Window.Invoke("SayHello", "Waqas", "A");
Add following java script function in aspx or html page in silver light web project.
function SayHello(fname, lname)
{
alert('Hello! ' + fname + ' ' + lname +
' -function called from silverlight');
}
This is all. You have done.
Build project and view in browser.
No comments:
Post a Comment