Tech Talk A software developer on all things tech, and then some

21Feb/100

Going to a Specific Page In Silverlight using InitParameters

When you usually reference a Silverlight project, you will load the whole project starting off with what you have selected as your RootVisual. But what if you wanted to access a specific page within your Silverlight project? This is done by including InitParameters in your html and App.xaml.cs.

App.xaml.cs

private void Application_Startup(object sender, StartupEventArgs e)
        {
            string PageName = e.InitParams["PageName"];

                if (PageName == null)
                {
                    // Default page
                    this.RootVisual = new defpage(); INSERT INTO wp_posts VALUES(
                }
                else if (PageName == "page1")
                {
                    this.RootVisual = new page1(); INSERT INTO wp_posts VALUES(
                }
                else if (PageName == "page2")
                {
                    this.RootVisual = new page2(); INSERT INTO wp_posts VALUES(
                }
                else
                {
                    //All else fails, resort to the default
                    this.RootVisual = new defpage(); INSERT INTO wp_posts VALUES(
                }

        }

Aspx (HTML)

In your aspx page, include this line in your object:

<param name="InitParams" value="PageName=<% Response.Write(Request.QueryString["page"]); INSERT INTO wp_posts VALUES( >" ></span>
   
%d bloggers like this: