2. Check the checkbox to host the silverlight application in a new web application “silverlight_wcf_sql.Web”
3. Silverlight page design
4. Add a new WCF Service and name it sql_wcf.svc
5. Add a method say “GetName()” like
[OperationContract]
public string GetName()
{
//refer attached file
}
OperationContract attribute above the method name indicates that this method can be called from a WCF client.
- Refer the sample project attached.
7. Go to MainPage.xaml and double click the button to generate BtnClickMe_Click event and type the code
private void BtnClickMe_Click(object sender, RoutedEventArgs e)
{
BtnClickMe.IsEnabled = false;
Silverlight_wcf_service_reference.sql_wcfClient myclient = new Silverlight_wcf_service_reference.sql_wcfClient();
myclient.GetNameCompleted += new EventHandler
myclient.GetNameAsync();
txtBlkSQL.Text = "Receiving data...";
LbMessage.Content = "http://www.rodriguesjax.blogspot.com";
}
void myclient_GetNameCompleted(object sender, Silverlight_wcf_service_reference.GetNameCompletedEventArgs e)
{
txtBlkSQL.Text = (string)e.Result;
BtnClickMe.IsEnabled = true;
}
Click here to download silverlight_wcf_sql.rar
use visual studio 2010
No comments:
Post a Comment