Silverlight to ASP.NET
To show Silverlight communicating with the ASP.NET site it is hosted within I have just set up a new Silverlight application and inserted a text box and a button, when I click the button I am wanting the Silverlight to change the property of the htmlText on the host page, to show the text entered in Silverlight.
First I must make sure that on the host (BlogDemo01TestPage.aspx) there is a item with the correct ID, here I have just used a header with ellipses.
1: <h3 id="htmlText">...</h3>
This is then used from the Silverlight code behind file to reference the object, so we can change the text. As we are wanting to talk via the browser to the ASP.NET page we must first add a new reference to the browser. Then with the Click event of the SL button.
This gets the element within the ASP.NET page with the ID of htmlText and replaces the innerText with that of what we entered in the SL text box.
ASP.NET to Silverlight
Now that we can successfully use Silverlight to communicate with the ASP.NET page we really would like it to happen in the opposite direction as well.
As you can see the code is now set up to call a method within the Silverlight page, which signature accepts no arguments and returns void.