interviews.dotnetthread.com

↑ Grab this Headline Animator

Wednesday, December 3, 2008

How to bind the value in drop down list in silverlight page from aspx page?

<script language="javascript" type="text/javascript">
function SelectionChanged(ddl) {
var sl = document.getElementById("Xaml1");
if (sl != null) {
sl.Content.SLapp.SLMethod(ddl.options[ddl.selectedIndex].value);
}
}
</script>

<asp:DropDownList ID="DropDownList1" runat="server" onChange="SelectionChanged(this)">
<asp:ListItem Text="Item 1" Value="Value 1" />
<asp:ListItem Text="Item 2" Value="Value 2" />
<asp:ListItem Text="Item 3" Value="Value 3" />
</asp:DropDownList>
<asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/TestSilverlight.xap"
MinimumVersion="2.0.30523" Width="100%" Height="100%" />

You can create your ListItem dynamically for the value I guess.


And Page.xaml.cs (with a TextBlock named text)



[ScriptableType]
public partial class Page : UserControl
{
public Page()
{
InitializeComponent();
HtmlPage.RegisterScriptableObject("SLapp", this);
}

[ScriptableMember]
public void SLMethod(string name)
{
text.Text = name;
}

}

Submit this story to DotNetKicks

No comments:

Post a Comment

Post your comments/questions/feedback for this Article.

 

Latest Articles