Click here to Skip to main content
15,888,984 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I have written a Silverlight 4 app. I tried to load initParams to pass to the out-of-browser app. Page_Load is never run.

My aspx file includes the following:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PackageInTestPage.aspx.cs" Inherits="PackageIn.Web.PackageInTestPage" %><body>
    <form id="form1"  runat="server" style="height:100%">
    <div id="silverlightControlHost">
        <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"><param name="initParams" value="<% =WebDotConfig%>" /></div>


My codebehind file, PackageInTestPage.aspx.cs looks like this:

C#
namespace PackageIn.Web
{
    public partial class PackageInTestPage : System.Web.UI.Page
    {
        public string WebDotConfig { get; set; }
        //This code does not appear to run
        protected void Page_Load(object sender, EventArgs e)
        {
            WebDotConfig = ""
            <code to="" fill="" in="" webdotconfig="">
            ...
</code>


I also tried adding the following code to the .aspx file with no luck:

XML
<script type="text/C#" language="c#" >
    public string WebDotConfig { get; set; }
    protected void Page_Load(object sender, EventArgs e)
    {
        WebDotConfig  = "PackageWeight1=" + ConfigurationManager.AppSettings["PackageWeight1"];
        WebDotConfig += ",TicketCount1=" + ConfigurationManager.AppSettings["TicketCount1"];
        WebDotConfig += ",MaxTicketsPerPackage=" + ConfigurationManager.AppSettings["MaxTicketsPerPackage"];
    }




The app will run but the initParams is always blank.
I tried inserting "throw new exception("xxx");" into the first line of Page_Load and it made no difference so I don't think the Page_Load was run. In the debugger, the breakpoint displays with the "!" saying the breakpoint will never be reached.
It is the same whether I run out-of-browser or not. If I set my PackageIn.Web project as the start up project, THEN the Page_Load will run.

I have tried a few variations in the codebehind= and inherits= values but that has not helped.

I have read multiple posts describing how to set initParams in Silverlight and I think I am following all the instructions.

If anyone can tell me what I am doing wrong or how to track down the problem, I would really appreciate it.
Posted
Updated 4-May-11 4:51am
v2

This works now. I think the problem was I was using initParams (lcase i) on server and InitParams (ucase I) on client. It appeared to be not running because I needed to set PackageIn.Web as start up project.
 
Share this answer
 
Comments
Michael Shupe 10-May-11 12:30pm    
Solved
This is text is just to mark the problem solved
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900