The functions of Silverlight and Flash are no different, but because it is developed on the. NET platform, you can modify it as needed. The source code can be downloaded at webcam.codeplex.com, but some machines with Windows 2003 installed may encounter errors when saving images.
Server side of the pageCodeLike the Flash version, no code is pasted, but the client must add
Code
< Div ID = "Avatarsilverlight" Style = "Clear: Both; display: none; width: 520px; Height: 300px ;" >
< Script Type = "Text/JavaScript" SRC = "<% = Localhost %>/Silverlight/Avatar/Silverlight. js" Reload = "1" > </ Script >
< Div ID = "Silverlightcontrolhost" Style = "Width: 520px; Height: 300px ;" >
< Object ID = "Avatarupload" Data = "Data: Application/x-silverlight-2 ," Type = "Application/x-silverlight-2"
Width = "520px" Height = "300px" >
< Param Name = "Source" Value = "<% = Localhost %>/Silverlight/Avatar/clientbin/webcam. xap" />
< Param Name = "Onerror" Value = "Onsilverlighterror" />
< Param Name = "Background" Value = "White" />
< Param Name = "Minruntimeversion" Value = "4.0.50401.0" />
< Param Name = "OnLoad" Value = "OnLoad" />
< Param Name = "Autoupgrade" Value = "True" />
< Param Name = "Initparams" Value = "Authtoken = adagiwinbm8 =, savepath =/images/upload/avatars/{0}/{0 }_" />
< A Href = "Http://go.microsoft.com/fwlink? Linkid = 149156 & V = 4.0.50401.0" Style = "Text-Decoration: none"
Target = "_ Blank" >
< IMG SRC = "<% = Localhost %>/Silverlight/Avatar/avatar.jpg" ALT = "Install the Microsoft Silverlight control and immediately use the silver Avatar"
Style = "Border-style: none" />
</ A >
</ Object >
</ Div >
< Script Type = "Text/JavaScript" >
Function Onload (plugin, usercontext, Sender ){
$ ( " Avatarupload " ). Content. javascriptobject. closeavatar = Updateavatar; // Register JS methods for Silverlight to call
}
</ Script >
</ Div >
<Param name = "Source" value = "<% = localhost %>/Silverlight/Avatar/clientbin/webcam. xap"/> is the path of the Silverlight file. If the server does not support xap files, you can change the file suffix to HTML.
<Param name = "initparams" value = "authtoken = adagiwinbm8 =, savepath =/images/upload/avatars/{0}/{0} _ "/> is used to set parameters for Silverlight. savepath is the path for saving images, the User ID of {0. The path of the servicepath WebService file remains unchanged.
Code download