Introducing DotNetFunda.com on mobile http://m.dotnetfunda.com ! Be with DotNetFunda.com on the go !
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 1893 |  Welcome, Guest!   Register  Login
Home > Articles > Silverlight > Silverlight 3 - Part 2

Silverlight 3 - Part 2

Article posted by Sudhakarj21 on 11/26/2009 | Views: 2869 | Category: Silverlight | Level: Beginner red flag


This Article will help to understand how the initial data required by Silverlight Application will be transfer to it from ASP.NET Page. This helps in transferring dynamic settings from ASP.NET Page to Silverlight application

Introduction
It is always required to transfer some data and details while starting a Silverlight application. These data are mostly required to init Silverlight application like URL for data service or some settings that are required to transfer from Web Application. This Article will help to understand how we can achieve using ASP.NET.
ASP.NET Sample

Create a new Silverlight application as discussed in Silverlight Part 1.

Go to ASP.NET Web Application and to Silverlight ASPX Test Page as below and Enter the data that you want to transfer to Silverlight. It is called InitParams in Silverlight application.

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">

              <param name="source" value="ClientBin/SilverlightApplication1.xap"/>

              <param name="onError" value="onSilverlightError" />

              <param name="background" value="white" />

              <param name="minRuntimeVersion" value="3.0.40818.0" />

              <param name="autoUpgrade" value="true" />

              <param name="InitParams" value="Param1=Test1234567890" />




These parameters can be accessed in your Silverlight Application in Application Init even as below.

Go to Silverlight application and App.Xaml.cs

private void Application_Startup(object sender, StartupEventArgs e)

        {

            this.RootVisual = new MainPage(e.InitParams["Param1"]);

             }

The above code transfers data to MainPage using constructor and we can set this data as Content to button as below

 

 

public MainPage(string cSetting)

        {

            InitializeComponent();

            TestBtn.Content = cSetting;

        }

<Button Grid.Row="0" Grid.Column="0" Content="Test" x:Name="TestBtn">

        </Button>

Conclusion

This Article just shows how we can transfer Init parameters from the ASP Page or Html Page to Silverlight Application. You can set the same using ASP.NET Server Control through ASP.NET Code Behind Dynamically.
In real time scenarios Init Parameters are widely to transfer Dynamic Settings which will be controlled by ASP.NET Code which will be executed and creates setting dynamically based on the requirements.

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

Experience:7 year(s)
Home page:
Member since:Monday, October 05, 2009
Level:Bronze
Status: [Member]
Biography:
>> Write Response - Respond to this post and get points
Related Posts

In this tutorial, we will see how to invoke Javascript function through Silverlight applications

In this article, we shall learn how to create custom splash (loading) screen in Silverlight.

In this article, we are going to learn how to work with WCF RIA Services in Silverlight.

Silverlight Notification API is a new feature introduced in Silverlight 4 Beta 1. If you are developing your application using Silverlight & want to show some notification message like Outlook to the user, then you can use this. Remember that, this feature only works out of browser.

In this article, we are going to explore the other Silverlight controls like Slider, Calendar and DatePicker and their properties.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/21/2012 7:22:23 AM