Best practice for integrating a silverlight control in a Asp.Net Solution

南楼画角 提交于 2019-12-11 07:05:25

问题


I need some advice regarding the handling of a Silverlight control that I need to integrate into an existing Website, coded with Asp.Net.

I'm using SVN, Visual Studio 2010, Framework 4.0. I need to create a simple silverlight control and I need to have it embedded in one of my asp.net pages.

My question is basically, what is the best practice on where to put this Silverlight control?

1) Creating a new project for my Silverlight control and then refer to it through an external tools within my website? (importing only the .xap?)

+ Reuse
- Seems lot of extra work for a small control

2) Create a new project withing my website solution, compile it next to my website and create a post build event to copy the .xap generated into a ClientBin folders in my website?

- Lack of reusability
+ Easy to make small modifications in my Silverlight component.

3) Another solution I don't know yet??

Thanks for your advices


回答1:


Do not worry about number of projects. Reuse is far more important (we have solutions with over 100 projects).

Create a new Silverlight application, then add a Silverlight relationship between the website and your new Silverlight application:

  • Right-click on your website project and select Properties.
  • Choose the Silverlight Applications tab on the left side
  • Press Add...
  • Leave Use an existing Silverlight project in the solution checked and select the project you want to add from the Project dropdown.
  • Leave Add a test page that references the control checked if you want a separate test page for your application.
  • Press Add and you are done.

The website will now build your Silverlight application and include the output Xap file in its ClientBin folder.

If you check "add a test page", that will give you sample HTML/ASPX pages and the JavaScript you need to run the Silverlight component anywhere in your ASP.Net app.



来源:https://stackoverflow.com/questions/9093540/best-practice-for-integrating-a-silverlight-control-in-a-asp-net-solution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!