Javascript 이벤트를 등록하고 수동으로 내 서버 컨트롤을 다시 호출했습니다.
<asp:Silverlight runat="server" ID="SilverlightUpload"
Source="~/ClientBin/Silverlight.xap" OnPluginLoaded="pluginLoaded" />
<asp:Button runat="server" OnClientClick="return cancelUpload()" Text="Cancel" />
<script type="text/javascript">
var uploadControl = null;
function pluginLoaded(sender) {
uploadControl = sender.get_element().content.uploadControl;
uploadControl.addEventListener("OnFileListChanged", onFileListChanged);
}
function onFileListChanged(sender, e) {
var files = [];
for (var i = 0; i < e.Files.length; i++) {
files[i] = {
Id : e.Files[i].Id,
Name : e.Files[i].Name
};
}
__doPostBack("<%= RadGrid1.UniqueID %>",
"OnFileListChanged:" + JSON.stringify(files));
}
function cancelUpload() {
$find("<%= SilverlightUpload.ClientID %>")
.get_element().content.uploadControl.StopUpload();
return false;
}
</script>
그리고 실버 라이트 코드 숨김 : 아래의 몇 가지 중요한 부분
[ScriptableType] // MUST
public partial class Page : UserControl
{
[ScriptableMember] // MUST
public event EventHandler<FileListChangedEventArgs> OnFileListChanged;
[ScriptableMember] // MUST
public void StopUpload() { }
}
[ScriptableType]
public class FileListChangedEventArgs : EventArgs
{
public FileUploadItem[] Files { get; internal set; }
}
[DataContract]
[ScriptableType]
public class FileUploadItem
{
}
좋은 점 (들). 내 컨트롤이 "재사용"미래에 페이지에 앉아 있지만, 생각하면 이제는 생각, asp.net 페이지에서 뭔가를 트리거하는 유일한 방법은 HTML 업데이트 또는 Javascript 것입니다. 트리거링. 컨트롤을 독립 실행 형으로 두는 것이 가장 좋습니다. –