Search All Articles Submit your Website or Blog to A New Internet Library
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;
}
}
Also Read other Top Articles
- JSON Serialization in VS 2008
- Implementing Forms Authentication in Silverlight Application.
- Making GridView Rows or Individual Cells Clickable and Selectable.
- Enabling browser back button for GridView Paging and Sorting in Ajax 1.1 and 3.5 (using Visual Studio 2005/ Visual studio 2008)
- How to pass values from User Control to Page or calling Page methods from User Control.
- What is WCF?
- New features in C# 4.0
- C# to VB.NET and VB.NET to C# online free converter tools.


0 comments:
Post a Comment
Post your comments/questions/feedback for this Article.