Lives: 30

Embedding Silverlight Upload in the page

Posted Wed Nov 25, 2009 @ 8:47 AM

The Silverlight Upload control has, up until 2003.3 SP 1 required the inclusion of System.Web.Silverlight.dll and the use of the Silverlight ASP control.

This requirement is due to the fact that Silverlight Upload requires two values provided via the InitParams tag, CartUploadId and CartTargetUrl.

Things have changed and now Silverlight Upload gives you 3 choices of how to use it on a page.

  1. The old way (deprecated):  No changes necessary.
  2. The new way, method 1: Using the new property SilverlightObjectID you can specify the ID of the object tag your Silverlight Upload control is placed in. It is not required to have an InitParams tag but if one exists the CartUploadId and CartTargetUrl variables are appended to the existing key-value pairs.
  3. The new way, method 2: Omit both SilverlightObjectID and SilverlightControlID and instead use this syntax for your InitParams tag: <param name="InitParams" value="CartUploadId=<%= SilverlightUpload1.UploadId %>,CartTargetUrl=<%= SilverlightUpload.GetResponseUrl(HttpContext.Current) %>" />

Example HTML for each method:

1.  The old way (deprecated):

<ComponentArt:SilverlightUpload ID="SilverlightUpload1" RunAt="server" 
    MaximumUploadSize="0"
    TempFileFolder="~/uploadtemp" 
    DestinationFolder="~/upload" 
    SilverlightControlId="Xaml1">
</ComponentArt:SilverlightUpload>
<!-- ... -->
<asp:Silverlight 
	ID="Xaml1" 
	runat="server" 
	Source="~/ClientBin/MySilverlightUploader.xap" 
	MinimumVersion="3.0.40624.0" 
	Width="100%" Height="100%" 
	Windowless="true"
/>

2.  Using the new property SilverlightObjectID:

<ComponentArt:SilverlightUpload ID="SilverlightUpload1" RunAt="server" 
    MaximumUploadSize="0"
    TempFileFolder="~/uploadtemp" 
    DestinationFolder="~/upload" 
    SilverlightObjectID="Object1">
</ComponentArt:SilverlightUpload>
<!-- ... -->
<object type="application/x-silverlight-2" data="data:application/x-silverlight-2," id="Object1" style="height:100%;width:100%;" >
	<param name="MinRuntimeVersion" value="2.0"></param>
	<param name="Windowless" value="True"></param>
	<!-- It is optional to have an InitParams tag at all.  If one exists the CartUploadId and CartTargetUrl are appended to it -->
	<param name="InitParams" value="MyVariable=SomeValue" />
	<param name="Source" value="ClientBin/MySilverlightUploader.xap" ></param>
	<a href="http://go2.microsoft.com/fwlink/?LinkID=114576&v=2.0">
		<img src="http://go2.microsoft.com/fwlink/?LinkID=108181" alt="Get Microsoft Silverlight" style="border-width:0;" />
	</a>
</object>

3.  Manual InitParams:

<ComponentArt:SilverlightUpload ID="SilverlightUpload1" RunAt="server" 
    MaximumUploadSize="0"
    TempFileFolder="~/uploadtemp" 
    DestinationFolder="~/upload">
</ComponentArt:SilverlightUpload>
<!-- ... -->
<object type="application/x-silverlight-2" data="data:application/x-silverlight-2," style="height:100%;width:100%;" >
	<param name="MinRuntimeVersion" value="2.0"></param>
	<param name="Windowless" value="True"></param>
	<param name="InitParams" value="CartUploadId=<%= SilverlightUpload1.UploadId %>,CartTargetUrl=<%= SilverlightUpload.GetResponseUrl(HttpContext.Current) %>" />
	<param name="Source" value="ClientBin/MySilverlightUploader.xap" ></param>
	<a href="http://go2.microsoft.com/fwlink/?LinkID=114576&v=2.0">
		<img src="http://go2.microsoft.com/fwlink/?LinkID=108181" alt="Get Microsoft Silverlight" style="border-width:0;" />
	</a>
</object>

Posted to Jeremy Rodgers by

Posted on Wed Nov 25, 2009 @ 8:47 AM

Filed under: ,

Comments

There are currently no comments for this blog post.

Anonymous comments are not allowed. Click here to log in or create an account.

Copyright © 2010 ComponentArt, Inc. All rights reserved.