locked
adding silverlight 1.1 project to existing vs2008 project RRS feed

  • Question

  • hello,

    i recently installed vs2008 and silverlight v1.1 and migrated my vwd2005 web site to a vs2008 web solution.  i have tried multiple migration paths, but am unable to get any of the xaml to load in a web page within the vs2008 project.  each project runs successfully on its own, e.g. the vs2008 debugs fine and the xaml project loads in blend2.  i also used the "Added a silverlight link" to connect the two projects in the vs2008 solution.  my question is how can i get the xaml to run in an existing aspx file that exists in the newly created vs2008 project?  i tried dragging/dropping a canvas, a page and an htlml file into the aspx file with no luck. only a hyperlink shows up in the debugged project.

     thanks!

    Thursday, February 14, 2008 7:10 PM

Answers

  • yes, my project was migrated to .net v3.5 during the vs2008 migration.  i did find the control in the asp.net futures download and the xaml worked great.  thanks for the help!

     

     

    Friday, February 15, 2008 6:09 AM

All replies

  • my question is how can i get the xaml to run in an existing aspx file that exists in the newly created vs2008 project?
     

    • ( As you have added "SilverlightLink" to VS2008 project, xaml file and dll are already copied to web project. )
    • Copy the Silverlight.js file and add that file to Web project
    • Reference this js file from the aspx page that you want to host Silverlight

        For example :  <script type="text/javascript" src="Silverlight.js"></script>

    • Add the javascript code

      <script type="text/javascript">
      function createSilverlight(){

                     Silverlight.createObjectEx({
                     source: "Page.xaml",
                     parentElement: document.getElementById("SilverlightControlHost"),
                     id: "SilverlightControl",
                     properties: {
                         width: "100%",
                         height: "100%",
                         version: "1.1",
                       enableHtmlAccess: "true"
                     },
                    events: {}
                    });
          
                     // Give the keyboard focus to the Silverlight control by default
                    document.body.onload = function() {
                        var silverlightControl = document.getElementById('SilverlightControl');
                         if (silverlightControl)silverlightControl.focus();
                    }

              }
          </script>

    •  Add the style


        <style type="text/css">
            .silverlightHost { width: 640px; height: 480px; }
        </style>

    •  Add the DIV where Silverlight object can host.


         <div id="SilverlightControlHost" class="silverlightHost" >
         </div>

      
     Hope it helps.

     

    Thursday, February 14, 2008 7:49 PM
  • thank you for the quick response.  unfortunately, i am not following the placement of this code into the appropriate files.  is there a way for vs2008 to setup this for me?  for example, if i want to add a new aspx page to the web project and then add the xaml to the aspx page, is there a particular form i can choose that places the appropriate code and services in the right location?

     

    Friday, February 15, 2008 1:04 AM
  • is there a way for vs2008 to setup this for me?
     

    Actually, If you are using ASP.NET 3.5 extension, there is a control called Silverligth control that allows you to show the Silverlight object (XAML)  in webpage with minimum effort. But I think your project is not ASP.NET 2.5 extension. so, you have two options 1) upgrade your project to ASP.NET 3.5 project or 2) follow the steps that I mentioned for adding silverlight object in aspx page. :)

    is there a particular form i can choose that places the appropriate code and services in the right location?

     Normally, we used to place the Silverlight dlls under ClientBin folder and xaml file under project folder. I don't think there is a guideline for that.

    Friday, February 15, 2008 1:15 AM
  • yes, my project was migrated to .net v3.5 during the vs2008 migration.  i did find the control in the asp.net futures download and the xaml worked great.  thanks for the help!

     

     

    Friday, February 15, 2008 6:09 AM