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.

 

6 Comments

  • 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!

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

  • 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.

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

  • 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;
    }
    }

  • Realy tks ! you is the best !

Comments have been disabled for this content.