<%@ Page Language="C#" AutoEventWireup="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>FileDragDrop</title>
    <style type="text/css">
    html, body {
	    height: 100%;
	    overflow: auto;
    }
    body {
	    padding: 0;
	    margin: 0;
    }
    #silverlightControlHost {
	    height: 100%;
	    text-align:center;
    }
    </style>
    <script type="text/javascript" src="Silverlight.js"></script>
    <script type="text/javascript">
        function onSilverlightError(sender, args) {
            var appSource = "";
            if (sender != null && sender != 0) {
              appSource = sender.getHost().Source;
            }
            
            var errorType = args.ErrorType;
            var iErrorCode = args.ErrorCode;

            if (errorType == "ImageError" || errorType == "MediaError") {
              return;
            }

            var errMsg = "Silverlight 응용 프로그램에서 처리되지 않은 오류 " +  appSource + "\n" ;

            errMsg += "코드: "+ iErrorCode + "    \n";
            errMsg += "범주: " + errorType + "       \n";
            errMsg += "메시지: " + args.ErrorMessage + "     \n";

            if (errorType == "ParserError") {
                errMsg += "파일: " + args.xamlFile + "     \n";
                errMsg += "줄: " + args.lineNumber + "     \n";
                errMsg += "위치: " + args.charPosition + "     \n";
            }
            else if (errorType == "RumtimeError") {           
                if (args.lineNumber != 0) {
                    errMsg += "줄: " + args.lineNumber + "     \n";
                    errMsg += "위치: " +  args.charPosition + "     \n";
                }
                errMsg += "메서드 이름: " + args.methodName + "     \n";
            }

            throw new Error(errMsg);
        }

        function UploadClick() {
            var host = document.getElementById("SilverlightControl");
            host.content.UploadFile.StartUpload();
        }

        function AbortItemOver() {
            alert("허용 개수 초과");
        }

        function AbortSizeOver() {
            alert("허용 용량 초과");
        }

        function AbortExtensionNot() {
            alert("지원하는 확장자 아님");
        }

        function AbortUploadNotFile() {
            alert("업로드 할 파일 없음");
        }

        function NotifyUploadComplete() {
            alert("업로드 완료");
            var host = document.getElementById("SilverlightControl");
            var uploadFile = new Array();
            uploadFile = host.content.UploadFile.UploadedFileName();

            Initialize();
        }

        function AbortDeleteFile() {
            alert("삭제할 파일이 없음");
        }

        function Initialize() {
            var host = document.getElementById("SilverlightControl");
            host.content.UploadFile.Initialize();
        }
    </script>
</head>
<body>
    <form id="form1" runat="server" style="height:100%">
    <input type="button" value="업로드" onclick="UploadClick()" />
    <div id="silverlightControlHost">
        <object id="SilverlightControl" data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">
		  <param name="source" value="ClientBin/FileDragDrop.xap"/>
		  <param name="onError" value="onSilverlightError" />
		  <param name="background" value="white" />
		  <param name="minRuntimeVersion" value="5.0.61118.0" />
		  <param name="autoUpgrade" value="true" />
          <param name="initParams" value="paramUrl=http://aspmssqlwa.nninc.co.kr/dev/uploader/FileUpload.ashx, paramFilter=.jpg|.zip|.txt, paramMaxFileSize=104857600, paramMaxFileNumber=5, prarmControlWidth=700, paramControlHeight=400"  />
		  <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=5.0.61118.0" style="text-decoration:none">
 			  <img src="http://go.microsoft.com/fwlink/?LinkId=161376" alt="Microsoft Silverlight 얻기" style="border-style:none"/>
		  </a>
	    </object><iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe></div>
    </form>
</body>
</html>
