Solution 3 : Passing Parameters from ASP.NET Page to Silverlight XAML

You have captured the login name and computer IP address in your ASP.NET page and you want to use the login name and IP address in your Silverlight XAML page for display, logging or access control. To implement this, you will need to pass the user name and IP address from the ASP.NET page to the Silverlight XAML.

1.       In your ASP.NET page code behind, declare a property named InitParams.

2.       In your ASP.NET Page_Load event, capture login name and IP address, and assign them to the InitParams property.

3.       In your ASP.NET page, set the value of initParams to the InitParams property.

4.       In your Silverlight App class, declare properties named LoginName and IPAddress.

5.       In your Silverlight App Startup event handler, retrieve values from initParams and assign them to the properties of LoginName and IPAddress.

6.       In any Silverlight XAML page, retrieve LoginName and IPAddress from the properties of App class.

 

Published Monday, December 7, 2009 10:07 PM by StanleyGu

Comments

# re: Passing Parameters from ASP.NET Page to Silverlight XAML

Sunday, December 20, 2009 8:13 AM by A.

Thanks for this post! Was searching a while for a clear explanation without any luck! I think that this is the easiest and most understandable post about this topic - thanks for sharing it!

# re: Solution 3 : Passing Parameters from ASP.NET Page to Silverlight XAML

Wednesday, November 17, 2010 3:08 PM by Robert

Thanks for the post.  Very easy to follow and understand.

# re: Solution 3 : Passing Parameters from ASP.NET Page to Silverlight XAML

Wednesday, November 24, 2010 1:17 AM by Jony

To pass the parameters from asp.net application to silver light XAP file,I followed the above steps, In that up to third step application working properly,Then i am doing get and set after that in 5th step i am getting parameter value as NULL instead of actual value is not coming.Please give me the solution solve my problem. Thanks in advance.

# re: Solution 3 : Passing Parameters from ASP.NET Page to Silverlight XAML

Thursday, January 6, 2011 6:21 AM by Vin

^^^ Same Problem...can anyone resolve this

# re: Solution 3 : Passing Parameters from ASP.NET Page to Silverlight XAML

Monday, January 10, 2011 5:52 AM by mitox

You have to implement the 6th step in MainPage Loaded event handler:

public partial class MainPage : UserControl

   {

       public MainPage()

       {

           InitializeComponent();

           this.Loaded += new RoutedEventHandler(MainPage_Loaded);

       }

       void MainPage_Loaded(object sender, RoutedEventArgs e)

       {

           App thisApp = (App)Application.Current;

           string logName = thisApp.LoginName;

           string ipAddress = thisApp.IPAddress;

       }

   }

# re: Solution 3 : Passing Parameters from ASP.NET Page to Silverlight XAML

Monday, December 5, 2011 9:16 AM by Alessandro Matsuoka

Realy tks ! you is the best !