Hi all,
My idea is to use Silverlight controls in my aspx. Perhaps this is not the way Silverlight should be used but I think It could be an interesting feature for ASP.NET.
I`ve an ASP.NET Web Page which have three <asp:Silverlight controls. One have a textbox, the other is a grid and the tirdth is a button. I use the same .xap an I pass the type of the control I want to load in the InitParameters. Then in the Application_Startup I create the control depending on the parameters (This way was expained in some post in this forum)
Now I would like to add an item to the grid when the button is clicked. The text of this item comes from the textbox :)
When the button is clicked I excecute javascript code using:
[
ScriptableMember]public event EventHandler ButtonClicked;public Boton()
{
InitializeComponent();
HtmlPage.RegisterScriptableObject("ScriptablePageObject", this);
}
private void btn_Click(object sender, RoutedEventArgs e)
{
if (ButtonClicked != null)
{
ButtonClicked(sender, e);
}
}
and
function pluginLoaded(sender,args) {
var slCtl = document.getElementById("Xaml3"); slCtl.Content.ScriptablePageObject.addEventListener("ButtonClicked", jsEventHandler);
}
function jsEventHandler(sender, args) {
alert("Se pulso el boton");
}
The problem I`m facing now is that I`m not able to interact between controls from javascript. For example, get the text from textbox or add values to the grid.
Is there any solution?
Thanks in advance