示例#1
0
        protected void ArtifactsGrid_HtmlEditFormCreated(object sender, ASPxGridViewEditFormEventArgs e)
        {
            ASPxGridView      gridView = (ASPxGridView)sender;
            ASPxUploadControl uploader = (ASPxUploadControl)gridView.FindEditFormLayoutItemTemplateControl("ArtifactUploader");

            uploader.AzureSettings.ContainerName = Session["enterpriseID"].ToString().ToLower();
        }
示例#2
0
        protected void uploader_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
        {
            string virtualPath = CommonConstants.STANDARD_PATH;
            string filePath    = "";

            ASPxUploadControl uc = (ASPxUploadControl)sender;
            GridViewEditItemTemplateContainer container = uc.NamingContainer as GridViewEditItemTemplateContainer;

            if (container != null)
            {
                filePath = Page.MapPath(virtualPath);
                //// Kiem tra Folder tao Folder neu chua co
                if (!Directory.Exists(filePath)) // TODO: needs to be created ONLY from setup phase with Security Permissions
                {
                    Directory.CreateDirectory(filePath);
                }

                // process a file
                var name = e.UploadedFile.FileName;
                e.UploadedFile.SaveAs(Page.MapPath(virtualPath + name));

                //ASPxPageControl pageControl = GridView.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
                //ASPxMemo memo = pageControl.FindControl("notesEditor") as ASPxMemo;
                //memo.Text;

                e.CallbackData = virtualPath + name;
            }
            else
            {
            }
        }
 protected override void OnInit(EventArgs e) {
     base.OnInit(e);
     _uploadControl = new ASPxUploadControl { ID = "uploadFile", Width = Unit.Pixel(300), ClientInstanceName = "_dxeUplFile" };
     _uploadControl.ClientSideEvents.FileUploadComplete = typeof(HtmlEditorCustomDialogTemlate).GetDxScriptFromResource("EditorFileUploadComplete.js");
     _uploadControl.FileUploadComplete += UploadControlOnFileUploadComplete;
     Controls.Add(_uploadControl);
 }
示例#4
0
 protected override System.Web.UI.WebControls.WebControl CreateEditModeControlCore()
 {
     control            = new ASPxUploadControl();
     control.UploadMode = UploadControlUploadMode.Advanced;
     control.AdvancedModeSettings.EnableFileList      = true;
     control.AdvancedModeSettings.EnableMultiSelect   = true;
     control.AdvancedModeSettings.EnableDragAndDrop   = true;
     control.ValidationSettings.AllowedFileExtensions = new string[] { ".jpg", ".png", ".psd", ".pdf", ".gif", ".docx", ".doc",
                                                                       ".xls", ".xlsx", ".txt", ".zip", ".rar", ".fla", ".swf" };
     control.ShowProgressPanel       = true;
     control.ShowUploadButton        = true;
     control.UploadButton.Text       = "Tải lên";
     control.NullText                = "Click để upload file Văn bản";
     control.NullTextStyle.Font.Bold = true;
     control.FileUploadComplete     += control_FileUploadComplete;
     // Bắt event ở client để re-render GridView
     // Tên của control được thay đổi ở file FileUploadViewController.cs
     control.ClientSideEvents.FilesUploadComplete = @"function(e) {
         eval('__Files__Uploaded__').Refresh();
         var initialYOffset = window.pageYOffset;
        
             var scroll = window.setInterval(function(){
                 window.scrollBy(0,50);
             },1000/60);
         var clearScroll = window.setInterval(function(){
             if(window.pageYOffset >= initialYOffset + 2000 || window.pageYOffset >= body.clientHeight - window.innerHeight) {
                     window.clearInterval(scroll);
                     window.clearInterval(clearScroll);
             }
         },500);
     }";
     current = this.CurrentObject as IMultiUpload;
     return(control);
 }
示例#5
0
        protected void ASPxGridView1_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            ASPxGridView      grid       = sender as ASPxGridView;
            ASPxTextBox       textBox    = FindPageControl(grid).FindControl("txtCauHoi") as ASPxTextBox;
            ASPxUploadControl uplControl = FindPageControl(grid).FindControl("uplImage") as ASPxUploadControl;

            e.NewValues["NOIDUNG"] = textBox.Text;
            e.NewValues["HINHANH"] = Session["uploadedFileData"];
        }
示例#6
0
        protected void ASPxUploadControl1_FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            ASPxUploadControl control = sender as ASPxUploadControl;
            CustomAppointmentFormTemplateContainer container = (CustomAppointmentFormTemplateContainer)Parent;
            string callback = SavePostedFiles(e.UploadedFile);

            container.Appointment.CustomFields["AppointmentAttachment"]         = e.UploadedFile.FileBytes;
            container.Appointment.CustomFields["AppointmentAttachmentFileName"] = callback;
            e.CallbackData = callback;
        }
示例#7
0
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     _uploadControl = new ASPxUploadControl {
         ID = "uploadFile", Width = Unit.Pixel(300), ClientInstanceName = "_dxeUplFile"
     };
     _uploadControl.ClientSideEvents.FileUploadComplete = typeof(HtmlEditorCustomDialogTemlate).GetDxScriptFromResource("EditorFileUploadComplete.js");
     _uploadControl.FileUploadComplete += UploadControlOnFileUploadComplete;
     Controls.Add(_uploadControl);
 }
示例#8
0
 protected void uploader_Init(object sender, EventArgs e)
 {
     if (bool.Parse(HttpContext.Current.Session["isDetailRow_Com"].ToString()))
     {
         ASPxUploadControl editor = sender as ASPxUploadControl;
         GridViewEditItemTemplateContainer container = editor.NamingContainer as GridViewEditItemTemplateContainer;
         //editor.ClientVisible = container.Grid.IsNewRowEditing; // or use the Visible property
         editor.ClientEnabled = container.Grid.IsNewRowEditing;
     }
 }
示例#9
0
        protected void PhotoGridView_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
        {
            ASPxUploadControl uc = PhotoGridView.FindEditRowCellTemplateControl((GridViewDataColumn)PhotoGridView.Columns["file_name"], "PhotoUploadControl") as ASPxUploadControl;

            if (uc != null)
            {
                uc.Visible = false;
            }
            e.Cancel = true;
            PhotoGridView.CancelEdit();
        }
示例#10
0
        //upload file tai day
        protected void uploadFileDinhKem_Load(object sender, FileUploadCompleteEventArgs e)
        {
            ASPxUploadControl upload = sender as ASPxUploadControl;

            if (!upload.FileName.ToString().Trim().Equals(""))
            {
                string filename     = string.Format("{0:ddMMyyyyhhmmss_}{1}", DateTime.Now, upload.FileName);
                string fullFilePath = Server.MapPath(DotNetNuke.Common.Globals.ApplicationPath + "/images/fileQD/") + filename;
                (sender as ASPxUploadControl).SaveAs(fullFilePath);
                Session["fileNangLuongA"] = filename;
            }
        }
示例#11
0
        public override System.Web.UI.Control Build()
        {
            base.Build();
            ASPxPanel         panel              = new ASPxPanel();
            ASPxUploadControl uploadfile         = new ASPxUploadControl();
            ASPxButton        uploadfilebutton   = new ASPxButton();
            ASPxLabel         uploadfileurl      = new ASPxLabel();
            ASPxButton        uploadfiledelete   = new ASPxButton();
            ASPxCallback      callbackfiledelete = new ASPxCallback();

            //定义上传框体
            uploadfile.BrowseButton.Text   = "浏览";
            uploadfile.ClientInstanceName  = "uploadfile";
            uploadfile.FileUploadComplete += new EventHandler <FileUploadCompleteEventArgs>(FileUploadComplete);
            //uploadfile.ClientSideEvents.FilesUploadComplete = "function(s, e) { Uploader_PicturesUploadComplete(e); }";
            uploadfile.ClientSideEvents.FileUploadComplete = "function(s, e) { Uploader_FileUploadComplete(e); }";
            uploadfile.ClientSideEvents.FileUploadStart    = "function(s, e) { Uploader_FileUploadStart(); }";
            uploadfile.ClientSideEvents.TextChanged        = "function(s, e) { FileUpdateUploadButton(); }";
            //uploadfile.ValidationSettings.MaxFileSize = 4194304;
            //string[] fileExtensions = new string[4] { ".jpg", ".jpeg", ".jpe", ".gif" };
            //uploadfile.ValidationSettings.AllowedFileExtensions = fileExtensions;

            //定义上传文件按钮
            uploadfilebutton.AutoPostBack           = false;
            uploadfilebutton.Text                   = "上传";
            uploadfilebutton.ClientEnabled          = false;
            uploadfilebutton.ClientInstanceName     = "uploadfilebutton";
            uploadfilebutton.ClientSideEvents.Click = "function(s, e) { uploadfiledeletefunc();uploadfile.Upload();}";
            //定义上传后文件名显示
            uploadfileurl.Text = "文件名:";
            uploadfileurl.ClientInstanceName = "uploadfileurl";
            //定义删除文件按钮
            uploadfiledelete.Text = "删除";
            uploadfiledelete.ClientInstanceName     = "uploadfiledelete";
            uploadfiledelete.ClientEnabled          = false;
            uploadfiledelete.ClientSideEvents.Click = "function(s, e) { uploadfiledeletefunc(); }";
            //callback回传服务器删除文件
            callbackfiledelete.ClientInstanceName = "callbackdeletefile";
            callbackfiledelete.Callback          += new CallbackEventHandler(OnCallbackDeleteFile);

            panel.Controls.Add(new LiteralControl("<table><tr><td>"));
            panel.Controls.Add(uploadfile);
            panel.Controls.Add(new LiteralControl("</td><td>"));
            panel.Controls.Add(uploadfilebutton);
            panel.Controls.Add(new LiteralControl("</td></tr><tr><td>"));
            panel.Controls.Add(uploadfileurl);
            panel.Controls.Add(new LiteralControl("</td><td>"));
            panel.Controls.Add(uploadfiledelete);
            panel.Controls.Add(new LiteralControl("</td></tr></table>"));
            panel.Controls.Add(callbackfiledelete);
            return(panel);
        }
示例#12
0
        //upload file tai day
        protected void uploadFileDinhKem_Load(object sender, FileUploadCompleteEventArgs e)
        {
            string            name   = "";
            ASPxUploadControl upload = sender as ASPxUploadControl;

            if (!upload.FileName.ToString().Trim().Equals(""))
            {
                string dv = "LCB" + DateTime.Now.ToShortDateString().Replace("/", "_") + "_";
                name = CreateServerFilename(upload.FileName);
                string fullFilePath = Server.MapPath(DotNetNuke.Common.Globals.ApplicationPath + "/images/fileQD/") + dv + name.Trim();
                (sender as ASPxUploadControl).SaveAs(fullFilePath);
            }
        }
示例#13
0
    protected void ASPxUploadControl_FileUploadComplete(object sender, DevExpress.Web.ASPxUploadControl.FileUploadCompleteEventArgs e)
    {
        ASPxUploadControl uploadControl = (ASPxUploadControl)sender;
        UploadedFile      uploadedFile  = uploadControl.UploadedFiles[0];

        e.CallbackData = Request.Url.AbsoluteUri.Replace(Request.Url.Query, String.Empty) + String.Format("?loadFile={0}", uploadedFile.FileName);
        try {
            Stream pdfStream = ConvertToPdf(uploadedFile.FileContent, uploadedFile.FileName);
            Session["UploadedFile"] = MemoryStreamHelper.ToBytes(pdfStream);
        } catch (Exception ex) {
            e.ErrorText = ex.Message;
            e.IsValid   = false;
        }
    }
        private void UploadControl_FilesUploadComplete(object sender, FilesUploadCompleteEventArgs e)
        {
            ASPxUploadControl uploadControl = (ASPxUploadControl)sender;

            foreach (UploadedFile uploadedFile in uploadControl.UploadedFiles)
            {
                PortfolioFileData fileData = ObjectSpace.CreateObject <PortfolioFileData>();
                fileData.Resume       = ViewCurrentObject;
                fileData.DocumentType = DocumentType.Unknown;
                fileData.File         = ObjectSpace.CreateObject <FileData>();
                fileData.File.LoadFromStream(uploadedFile.FileName, uploadedFile.FileContent);
            }
            ObjectSpace.CommitChanges();
        }
        private ASPxPanel editorSetup()
        {
            ASPxPanel editorPanel = new ASPxPanel();

            editorPanel.Width = Unit.Percentage(100);
            ASPxUploadControl upPanel = new ASPxUploadControl();

            upPanel.ID             = "upPanel";
            upPanel.FileUploadMode = UploadControlFileUploadMode.OnPageLoad;
            upPanel.ViewStateMode  = System.Web.UI.ViewStateMode.Enabled;
            upPanel.UploadMode     = UploadControlUploadMode.Auto; //Standard
            //upPanel.AddUploadButtonsHorizontalPosition = AddUploadButtonsHorizontalPosition.InputRightSide;
            upPanel.ShowProgressPanel = true;
            //upPanel.ShowAddRemoveButtons = true;
            upPanel.ProgressBarSettings.DisplayMode          = DevExpress.Web.ProgressBarDisplayMode.Percentage;
            upPanel.ValidationSettings.AllowedFileExtensions = new string[] { ".jpg", ".png", ".psd", ".pdf", ".gif", ".docx", ".doc",
                                                                              ".xls", ".xlsx", ".txt", ".zip", ".rar", ".fla", ".swf" };
            upPanel.ShowUploadButton               = true;
            upPanel.UploadButton.Image.Url         = "Images/upload.png";
            upPanel.UploadButton.Image.UrlDisabled = "Images/upload_disable.png";
            upPanel.UploadButton.ImagePosition     = DevExpress.Web.ImagePosition.Left;
            if (PropertyValue != null && PropertyValue.GetType() == typeof(FileUploads))
            {
                fileuploads = (FileUploads)PropertyValue;
            }
            upPanel.NullText = fileuploads == null ? "Click để chọn file upload.." : string.Format("{0}", fileuploads.Name);
            //upPanel.NullText = string.Format("File hiện tại: {0}", fileuploads == null ? "N/A" : fileuploads.Name);
            //Cho phep chon & upload nhieu file
            upPanel.AdvancedModeSettings.EnableMultiSelect = false;

            upPanel.FileUploadComplete += new EventHandler <FileUploadCompleteEventArgs>(uploadPanel_FileUploadComplete);
            //upPanel.PreRender
            //upPanel.CustomJSProperties

            ASPxLabel label   = new ASPxLabel();
            ASPxLabel lblNote = new ASPxLabel();

            lblNote.Text      = "Các bước UPLOAD file: \n1.Bấm 'Browse..' để chọn file.\n2. Bấm 'Upload' để tải file lên.\n3. Bấm 'Lưu' để xác nhận, file sẽ được lưu lên máy chủ.";
            lblNote.ForeColor = System.Drawing.Color.Gray;
            lblNote.BackColor = System.Drawing.Color.FromArgb(0xF2, 0xF2, 0xF2);
            label.ID          = "upLabelPanel";

            editorPanel.Controls.Add(label);
            editorPanel.Controls.Add(upPanel);
            editorPanel.Controls.Add(lblNote);
            return(editorPanel);
        }
    protected void ASPxUploadControl1_FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
    {
        ASPxUploadControl uploadControl = (ASPxUploadControl)sender;
        UploadedFile      uploadedFile  = uploadControl.UploadedFiles[0];

        if (!IsFileNameCorrect(uploadedFile.FileName))
        {
            e.IsValid   = false;
            e.ErrorText = "Incorrect file type";
            return;
        }

        if (uploadedFile.IsValid)
        {
            Session["UploadedFile"] = GetBytes(uploadedFile.FileContent);
        }
    }
        protected void UploadControl1_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
        {
            try
            {
                string contentType = HttpContext.Current.Request.Files[0].ContentType;
                Logger.Log(string.Format("Tryed content type is {0} ({1})", contentType, e.UploadedFile.FileName), LogLevel.Info);
                if (Path.GetExtension(e.UploadedFile.FileName) != ".xls")
                {
                    e.IsValid      = false;
                    e.CallbackData = Utilities.GetResourceString("Validators", "NotAllowedContentTypeError");
                    return;
                }

                // getting DistributorId
                ASPxUploadControl ctrl = sender as ASPxUploadControl;
                if (ctrl != null && distributorIds.Keys.FirstOrDefault(k => k == ctrl.ID) == null)
                {
                    e.IsValid      = false;
                    e.CallbackData = "Vyberte distributora";
                    return;
                }

                int distributorId = distributorIds[ctrl.ID];

                string filename = FileUtils.SavePostedFile(e.UploadedFile);
                CanonDistributorImport <CanonImportDistributorRecord> import = new CanonDistributorImport <CanonImportDistributorRecord>(filename, distributorId, e.UploadedFile.FileName);
                if (!import.ExportToDb())
                {
                    e.IsValid      = false;
                    e.CallbackData = "Chyba při zpracování. Importovací soubor nemá správný formát.";
                }
                else
                {
                    e.IsValid      = true;
                    e.CallbackData = "Import proběhl úspěšně.";
                }
            }
            catch (Exception ex)
            {
                e.IsValid   = false;
                e.ErrorText = Utilities.GetResourceString("Validators", "GeneralFileImportError");
                Logger.Log(string.Format("File {0}, exception {1}", e.UploadedFile.FileName, ex.ToString()),
                           LogLevel.Error);
            }
        }
示例#18
0
        public override System.Web.UI.Control Build()
        {
            base.Build();
            ASPxPanel         panel               = new ASPxPanel();
            ASPxUploadControl MUploadControl      = new ASPxUploadControl();
            ASPxRoundPanel    MUploadRoundPanel   = new ASPxRoundPanel();
            PanelContent      MUploadPanelContent = new PanelContent();

            //对上传控件的定义
            MUploadControl.ShowAddRemoveButtons = true;
            MUploadControl.BrowseButton.Text    = "浏览";
            MUploadControl.UploadButton.Text    = "上传";
            MUploadControl.AddButton.Text       = "添加";
            MUploadControl.RemoveButton.Text    = "移除";
            MUploadControl.Width            = 300;
            MUploadControl.ShowUploadButton = true;
            MUploadControl.AddUploadButtonsHorizontalPosition = AddUploadButtonsHorizontalPosition.Left;
            MUploadControl.ShowProgressPanel   = true;
            MUploadControl.ClientInstanceName  = "MUploadControl";
            MUploadControl.FileUploadComplete += new EventHandler <FileUploadCompleteEventArgs>(FilesUploadComplete);
            MUploadControl.FileInputCount      = 3;
            //MUploadControl.ValidationSettings.MaxFileSize = 4194304;
            //string[] fileExtensions = new string[4] { ".jpg", ".jpeg", ".jpe", ".gif" };
            //MUploadControl.ValidationSettings.AllowedFileExtensions = fileExtensions;
            MUploadControl.ClientSideEvents.FileUploadComplete = "function(s, e) { FilesUploaded(s, e) }";
            MUploadControl.ClientSideEvents.FileUploadStart    = "function(s, e) { FilesUploadStart(); }";

            //对上传显示的定义
            MUploadRoundPanel.Width = 300;
            MUploadRoundPanel.ClientInstanceName = "MUploadRoundPanel";
            MUploadRoundPanel.HeaderText         = "上传文件列表";

            //RoundPanel内部插件
            MUploadPanelContent.Controls.Add(new LiteralControl("<div id='uploadedListFiles' style='height: 150px; font-family: Arial;'></div>"));
            MUploadRoundPanel.Controls.Add(MUploadPanelContent);
            //MUploadRoundPanel.Height = 100%;

            //构建panel
            panel.Controls.Add(new LiteralControl("<table><tr><td>"));
            panel.Controls.Add(MUploadControl);
            panel.Controls.Add(new LiteralControl("</td><td>"));
            panel.Controls.Add(MUploadRoundPanel);
            panel.Controls.Add(new LiteralControl("</td></tr></table>"));
            return(panel);
        }
示例#19
0
        private void editorRender(ref ASPxPanel editorPanel)
        {
            ASPxUploadControl upPanel = (ASPxUploadControl)(editorPanel.FindControl("upPanel"));
            ASPxLabel         label   = (ASPxLabel)(editorPanel.FindControl("upLabelPanel"));

            if (upPanel != null)
            {
                upPanel.NullText = fileuploads == null ? "Click để chọn file từ PC.." : string.Format("{0}", fileuploads.FileName);
            }

            if (label != null && CurrentObject != null && isUploadComplete)
            {
                label.Text      = string.Format("File '{0}' đã upload thành công!", ((FileUploads)CurrentObject).FileName);
                label.ForeColor = System.Drawing.Color.FromArgb(0x33, 0x66, 0x00);
                label.Visible   = true;
                this.Refresh();
            }
        }
示例#20
0
        protected void ucFile_FilesUploadComplete(object sender, DevExpress.Web.FilesUploadCompleteEventArgs e)
        {
            var               rand    = new Random();
            string            tempDir = rand.Next(1, 999).ToString();
            string            newpath = MapPath("~/Content/Q/") + tempDir + "_\\";
            ASPxUploadControl fup     = sender as ASPxUploadControl;

            if (!Directory.Exists(newpath))
            {
                Directory.CreateDirectory(newpath);
            }

            foreach (DevExpress.Web.UploadedFile file in fup.UploadedFiles)
            {
                file.SaveAs(newpath + file.FileName);
            }
            Session["tempDir"] = tempDir;
        }
        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();
            ControlViewItem fileAttachmentsControl = (ControlViewItem)View.FindItem("FileAttachmentsControl");

            if (fileAttachmentsControl.Control != null)
            {
                ASPxUploadControl uploadControl = (ASPxUploadControl)fileAttachmentsControl.Control;
                uploadControl.UploadMode       = UploadControlUploadMode.Advanced;
                uploadControl.ShowUploadButton = true;
                uploadControl.AdvancedModeSettings.EnableDragAndDrop = true;
                uploadControl.AdvancedModeSettings.EnableFileList    = true;
                uploadControl.AdvancedModeSettings.EnableMultiSelect = true;
                uploadControl.FilesUploadComplete += UploadControl_FilesUploadComplete;
                uploadControl.ClientSideEvents.FilesUploadStart = "function (s, e) { e.cancel = !confirm('All changes will be saved to the database. Continue?'); }";
                string callbackScript = CallbackManager.GetScript();
                uploadControl.ClientSideEvents.FilesUploadComplete = $"function(s, e) {{ {callbackScript} }}";
            }
        }
示例#22
0
        protected void fileUP_FileUploadComplete(object sender, DevExpress.Web.FileUploadCompleteEventArgs e)
        {
            //send back filename and filename in azurestorage to be handled client side, where a callback for storing the data
            // will  be called - this is because the fileuploader has its own callback for uploading the file, handled in this event

            // e.CallbackData = e.UploadedFile.FileName + "|" + e.UploadedFile.FileNameInStorage;

            //routine from pro_repository.aspx to extract text - both should be moved to rc_services
            string FileExtn = "", plainText = "";

            ASPxUploadControl ArtifactUploader = (ASPxUploadControl)sender;
            string            accountName      = ArtifactUploader.AzureSettings.AccountName;
            //string containerName =ArtifactUploader.AzureSettings.ContainerName; --does not work, even though blob is uploded to proper container
            string containerName               = Session["enterpriseID"].ToString().ToLower();
            string url = GetFileUrl(e.UploadedFile.FileNameInStorage, accountName, containerName, ref FileExtn);

            if (FileExtn == ".txt" || FileExtn == ".doc" || FileExtn == ".docx")
            {
                using (var client = new System.Net.WebClient())
                {
                    client.DownloadFile(url, Path.GetTempPath() + "\\" + e.UploadedFile.FileName);
                }

                RichEditDocumentServer richEditDocument = new RichEditDocumentServer();
                richEditDocument.LoadDocument(Path.GetTempPath() + "\\" + e.UploadedFile.FileName);
                plainText = richEditDocument.Text;
            }
            else if (FileExtn == ".pdf")
            {
                using (var client = new System.Net.WebClient())
                {
                    client.DownloadFile(url, Path.GetTempPath() + "\\" + e.UploadedFile.FileName);
                }

                using (PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor())
                {
                    documentProcessor.LoadDocument(Path.GetTempPath() + "\\" + e.UploadedFile.FileName);
                    plainText = documentProcessor.Text;
                }
            }
            e.CallbackData = e.UploadedFile.FileName + "|" + e.UploadedFile.FileNameInStorage + "|" + plainText;
            paramUpload.Clear();
        }
        //filename : use filename from control
        //documentTypeId : use id of table(type)
        //ctrl : use ASPxUploadControl from webpage
        //return path for save file
        public string UploadFile(string fileName, int documentTypeId, ASPxUploadControl ctrl)
        {
            string dir = "~/Documents/" + HttpContext.Current.Session["userName"] + "/" + documentTypeId + "/";
            bool isExist = System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(dir));
            if (!isExist)
            {
                System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(dir));
            }

            Document x = new Document();
            x.Path = dir + fileName;
            x.IdentityId = Convert.ToInt32(HttpContext.Current.Session["id"]);
            x.DocumentTypeId = documentTypeId;
            x.FileName = fileName;
            db.Documents.InsertOnSubmit(x);
            db.SubmitChanges();

            return dir;
        }
    protected void CourseUC_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
    {
        ASPxUploadControl uploadControl = sender as ASPxUploadControl;

        if (uploadControl.UploadedFiles != null || uploadControl.UploadedFiles.Length > 0)
        {
            for (int i = 0; i < uploadControl.UploadedFiles.Length; i++)
            {
                UploadedFile file = uploadControl.UploadedFiles[i];
                PublicValue.relativePath = file.FileName;

                if (file.FileName != "")
                {
                    string fullPath = string.Format("{0}{1}", Server.MapPath("../../../img/"), file.FileName);
                    //参数true用于指明当保存的目录下有同名文件时将其覆盖
                    file.SaveAs(fullPath, true);
                }
            }
        }
    }
    protected void ASPxUploadControl1_FilesUploadComplete(object sender, DevExpress.Web.ASPxUploadControl.FilesUploadCompleteEventArgs e)
    {
        // Intentionally pauses server-side processing to demonstrate the Loading Panel or Progress Panel functionality
        System.Threading.Thread.Sleep(2000);

        ASPxUploadControl uploadControl = sender as ASPxUploadControl;

        if (uploadControl.UploadedFiles != null && uploadControl.UploadedFiles.Length > 0)
        {
            for (int i = 0; i < uploadControl.UploadedFiles.Length; i++)
            {
                UploadedFile file = uploadControl.UploadedFiles[i];
                if (file.FileName != "")
                {
                    string fileName = string.Format("{0}{1}", MapPath("~/Images/"), file.FileName);
                    //file.SaveAs(fileName, true);//OnLine Demo Restriction
                }
            }
        }
    }
示例#26
0
        protected void ArtifactUploader_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
        {
            string FileExtn = "", plainText = "";

            ASPxUploadControl ArtifactUploader = (ASPxUploadControl)sender;
            string            accountName      = ArtifactUploader.AzureSettings.AccountName;
            //string containerName =ArtifactUploader.AzureSettings.ContainerName; --does not work, even though blob is uploded to proper container
            string containerName               = Session["enterpriseID"].ToString().ToLower();
            string url = GetFileUrl(e.UploadedFile.FileNameInStorage, accountName, containerName, ref FileExtn);

            if (FileExtn == ".txt" || FileExtn == ".doc" || FileExtn == ".docx")
            {
                using (var client = new System.Net.WebClient())
                {
                    client.DownloadFile(url, Path.GetTempPath() + "\\" + e.UploadedFile.FileName);
                }
                //ASPxRichEdit richEdit = new ASPxRichEdit();
                //richEdit.Open("~\\App_Data\\" + e.UploadedFile.FileName);
                //MemoryStream ms = new MemoryStream();
                //richEdit.SaveCopy(ms, DocumentFormat.PlainText);
                //ms.Seek(0, SeekOrigin.Begin);
                //plainText = new StreamReader(ms).ReadToEnd();
                RichEditDocumentServer richEditDocument = new RichEditDocumentServer();
                richEditDocument.LoadDocument(Path.GetTempPath() + "\\" + e.UploadedFile.FileName);
                plainText = richEditDocument.Text;
            }
            else if (FileExtn == ".pdf")
            {
                using (var client = new System.Net.WebClient())
                {
                    client.DownloadFile(url, Path.GetTempPath() + "\\" + e.UploadedFile.FileName);
                }

                using (PdfDocumentProcessor documentProcessor = new PdfDocumentProcessor())
                {
                    documentProcessor.LoadDocument(Path.GetTempPath() + "\\" + e.UploadedFile.FileName);
                    plainText = documentProcessor.Text;
                }
            }
            e.CallbackData = e.UploadedFile.FileName + "|" + e.UploadedFile.FileNameInStorage + "|" + plainText;
        }
示例#27
0
        public string UploadFileDoc(string fileName, int DocTypeId, ASPxUploadControl ctrl, object mapId)
        {
            string MId = mapId.ToString();
            string dir = "~/Documents/" + HttpContext.Current.Session["UserName"] + "/" + HttpContext.Current.Session["DurationId"] + "/" + DocTypeId + "/" + MId + "/";
            bool isExist = System.IO.Directory.Exists(HttpContext.Current.Server.MapPath(dir));
            if (!isExist)
            {
                System.IO.Directory.CreateDirectory(HttpContext.Current.Server.MapPath(dir));
            }

            Doc_Main x = new Doc_Main();
            x.Path = dir + fileName;
            x.UserName = HttpContext.Current.Session["UserName"].ToString();
            x.DurationId = Convert.ToInt32(HttpContext.Current.Session["DurationId"]);
            x.FileName = fileName;
            x.DocumentTypeId = DocTypeId;
            x.MapId = MId;
            db.Doc_Mains.InsertOnSubmit(x);
            db.SubmitChanges();

            return dir;
        }
示例#28
0
        public override System.Web.UI.Control Build()
        {
            base.Build();
            ASPxPanel         panel           = new ASPxPanel();
            ASPxUploadControl uploadpctrl     = new ASPxUploadControl();
            ASPxButton        uploadpbutton   = new ASPxButton();
            ASPxTextBox       uploadptext     = new ASPxTextBox();
            ASPxButton        previewpbutton  = new ASPxButton();
            ASPxButton        clippingpbutton = new ASPxButton();
            ASPxButton        clearpbutton    = new ASPxButton();
            ASPxButton        savepbutton     = new ASPxButton();
            ASPxRoundPanel    listpround      = new ASPxRoundPanel();
            PanelContent      listcontent     = new PanelContent();
            ASPxGridView      listgrid        = new ASPxGridView();

            //上传控件
            uploadpctrl.ClientInstanceName = "uploadpctrl" + ModuleField.FieldID;
            uploadpctrl.BrowseButton.Text  = "浏览";
            uploadpctrl.Width = Unit.Percentage(100);
            uploadpctrl.ClientSideEvents.TextChanged        = "function(s,e){TextChangedEvent(" + ModuleField.FieldID + ");}";
            uploadpctrl.ClientSideEvents.FileUploadStart    = "function(s,e){FileUploadStartEvent(" + ModuleField.FieldID + ");}";
            uploadpctrl.ClientSideEvents.FileUploadComplete = "function(s,e){FileUploadCompleteEvent(" + ModuleField.FieldID + ",e);}";
            uploadpctrl.FileUploadComplete += new EventHandler <FileUploadCompleteEventArgs>(uploadpctrl_FileUploadComplete);
            //上传按钮
            uploadpbutton.ClientInstanceName = "uploadpbutton" + ModuleField.FieldID;
            uploadpbutton.AutoPostBack       = false;
            uploadpbutton.Text                   = "上传";
            uploadpbutton.Width                  = 45;
            uploadpbutton.Height                 = 25;
            uploadpbutton.ClientEnabled          = false;
            uploadpbutton.ClientSideEvents.Click = "function(s,e){uploadpctrl" + ModuleField.FieldID + ".Upload();}";
            //文件名text
            uploadptext.ClientInstanceName = "uploadptext" + ModuleField.FieldID;
            uploadptext.Width    = Unit.Percentage(100);
            uploadptext.Height   = 25;
            uploadptext.ReadOnly = true;
            //预览按钮
            previewpbutton.ClientInstanceName = "previewpbutton" + ModuleField.FieldID;
            previewpbutton.AutoPostBack       = false;
            previewpbutton.Text                   = "预览";
            previewpbutton.Width                  = Unit.Percentage(100);
            previewpbutton.Height                 = 25;
            previewpbutton.ClientEnabled          = false;
            previewpbutton.ClientSideEvents.Click = "function(s,e){PreviewClickEvent(" + ModuleField.FieldID + ");}";
            //预览按钮弹出窗口
            #region 弹出窗口
            ASPxPopupControl previewpopup = new ASPxPopupControl();
            previewpopup.ClientInstanceName = "previewpopup" + ModuleField.FieldID;
            previewpopup.CloseAction        = CloseAction.CloseButton;
            previewpopup.HeaderText         = "图片预览";
            previewpopup.Modal                = true;
            previewpopup.AllowDragging        = true;
            previewpopup.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
            previewpopup.PopupVerticalAlign   = PopupVerticalAlign.WindowCenter;
            previewpopup.Controls.Add(new LiteralControl("<div style='width:500px;height:375px;text-align:center;overflow:scroll;'><img id='previewimage" + ModuleField.FieldID + "' alt='' src='' /></div>"));
            #endregion
            //剪裁按钮
            clippingpbutton.ClientInstanceName = "clippingpbutton" + ModuleField.FieldID;
            clippingpbutton.AutoPostBack       = false;
            clippingpbutton.Text                   = "剪裁";
            clippingpbutton.Width                  = 45;
            clippingpbutton.Height                 = 25;
            clippingpbutton.ClientEnabled          = false;
            clippingpbutton.ClientSideEvents.Click = "function(s,e){ClippingClickEvent(" + ModuleField.FieldID + ");}";
            //剪裁按钮弹出窗口
            #region 弹出窗口
            ASPxPopupControl clippingpopup = new ASPxPopupControl();
            clippingpopup.ClientInstanceName = "clippingpopup" + ModuleField.FieldID;
            clippingpopup.CloseAction        = CloseAction.CloseButton;
            clippingpopup.HeaderText         = "图片剪裁";
            clippingpopup.Modal                = true;
            clippingpopup.AllowDragging        = true;
            clippingpopup.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
            clippingpopup.PopupVerticalAlign   = PopupVerticalAlign.WindowCenter;
            ASPxLabel     lbX1                 = new ASPxLabel();
            ASPxLabel     lbX2                 = new ASPxLabel();
            ASPxLabel     lbY1                 = new ASPxLabel();
            ASPxLabel     lbY2                 = new ASPxLabel();
            ASPxLabel     lbW                  = new ASPxLabel();
            ASPxLabel     lbH                  = new ASPxLabel();
            ASPxLabel     lbwh                 = new ASPxLabel(); lbwh.Text = "自定义长宽:";
            ASPxButton    bwh                  = new ASPxButton(); bwh.Text = "确定修改";
            ASPxButton    clippingsubmit       = new ASPxButton(); clippingsubmit.Text = "确定剪裁";
            ASPxButton    clippingcancel       = new ASPxButton(); clippingcancel.Text = "取消剪裁";
            StringBuilder clippingpicshowtable = new StringBuilder();
            clippingpicshowtable.Append("<table><tr><td>");
            clippingpicshowtable.Append("<table cellpadding='0' cellspacing='0'><tr><td>");
            clippingpicshowtable.Append("<div style='width:500px;height:375px;text-align:center;overflow:scroll;'><img id='clippingimage" + ModuleField.FieldID + "' alt='' src='' /></div>");
            clippingpicshowtable.Append("</td><td>");
            clippingpicshowtable.Append("<table><tr><td align='center'><div style='width:180px;height:180px;'><div id='smalldiv1" + ModuleField.FieldID + "' style='width:180px;height:180px;overflow:hidden;'><img id='small1" + ModuleField.FieldID + "' alt='' src='' /></div></div></td></tr>");
            clippingpicshowtable.Append("<tr><td align='center'><div style='width:120px;height:120px;'><div id='smalldiv2" + ModuleField.FieldID + "' style='width:120px;height:120px;overflow:hidden;'><img id='small2" + ModuleField.FieldID + "' alt='' src='' /></div></div></td></tr>");
            clippingpicshowtable.Append("<tr><td align='center'><div style='width:60px;height:60px;'><div id='smalldiv3" + ModuleField.FieldID + "' style='width:60px;height:60px;overflow:hidden;'><img id='small3" + ModuleField.FieldID + "' alt='' src='' /><div></div></td></tr></table>");
            clippingpicshowtable.Append("</td></tr></table></td></tr><tr><td>");
            clippingpopup.Controls.Add(new LiteralControl(clippingpicshowtable.ToString()));
            clippingpopup.Controls.Add(new LiteralControl("<table><tr><td>"));
            clippingpopup.Controls.Add(lbX1); clippingpopup.Controls.Add(new LiteralControl("</td><td>"));
            clippingpopup.Controls.Add(lbY1); clippingpopup.Controls.Add(new LiteralControl("</td><td>"));
            clippingpopup.Controls.Add(lbX2); clippingpopup.Controls.Add(new LiteralControl("</td><td>"));
            clippingpopup.Controls.Add(lbY2); clippingpopup.Controls.Add(new LiteralControl("</td><td>"));
            clippingpopup.Controls.Add(lbW); clippingpopup.Controls.Add(new LiteralControl("</td><td>"));
            clippingpopup.Controls.Add(lbH); clippingpopup.Controls.Add(new LiteralControl("</td></tr><tr><td>"));
            clippingpopup.Controls.Add(new LiteralControl("<label>X1 <input type='text' size='4' id='X1" + ModuleField.FieldID + "' name='X1" + ModuleField.FieldID + "' readonly='readonly' /></label></td><td>"));
            clippingpopup.Controls.Add(new LiteralControl("<label>Y1 <input type='text' size='4' id='Y1" + ModuleField.FieldID + "' name='Y1" + ModuleField.FieldID + "' readonly='readonly' /></label></td><td>"));
            clippingpopup.Controls.Add(new LiteralControl("<label>X2 <input type='text' size='4' id='X2" + ModuleField.FieldID + "' name='X2" + ModuleField.FieldID + "' readonly='readonly' /></label></td><td>"));
            clippingpopup.Controls.Add(new LiteralControl("<label>Y2 <input type='text' size='4' id='Y2" + ModuleField.FieldID + "' name='Y2" + ModuleField.FieldID + "' readonly='readonly' /></label></td><td>"));
            clippingpopup.Controls.Add(new LiteralControl("<label>W <input type='text' size='4' id='W" + ModuleField.FieldID + "' name='W" + ModuleField.FieldID + "' /></label></td><td>"));
            clippingpopup.Controls.Add(new LiteralControl("<label>H <input type='text' size='4' id='H" + ModuleField.FieldID + "' name='H" + ModuleField.FieldID + "' /></label></td></tr>"));
            clippingpopup.Controls.Add(new LiteralControl("<tr><td colspan='4'><input type='checkbox' id='ar_lock" + ModuleField.FieldID + "'/><label for='ar_lock'>固定为正方</label></td><td>"));
            clippingpopup.Controls.Add(lbwh);
            clippingpopup.Controls.Add(new LiteralControl("</td><td>"));
            clippingpopup.Controls.Add(bwh);
            clippingpopup.Controls.Add(new LiteralControl("</td></tr><tr><td colspan='3' align='right'>"));
            clippingpopup.Controls.Add(clippingsubmit);
            clippingpopup.Controls.Add(new LiteralControl("</td><td colspan='3' align='left'>"));
            clippingpopup.Controls.Add(clippingcancel);
            clippingpopup.Controls.Add(new LiteralControl("</td></tr></table>"));
            clippingpopup.Controls.Add(new LiteralControl("</td></tr></table>"));
            #endregion
            //清空按钮
            clearpbutton.ClientInstanceName = "clearpbutton" + ModuleField.FieldID;
            clearpbutton.AutoPostBack       = false;
            clearpbutton.Text                   = "清空";
            clearpbutton.Width                  = 45;
            clearpbutton.Height                 = 25;
            clearpbutton.ClientEnabled          = false;
            clearpbutton.ClientSideEvents.Click = "function(s,e){ClearClickEvent(" + ModuleField.FieldID + ");}";
            //保存按钮
            savepbutton.ClientInstanceName = "savepbutton" + ModuleField.FieldID;
            savepbutton.AutoPostBack       = false;
            savepbutton.Text          = "保存";
            savepbutton.Width         = Unit.Percentage(100);
            savepbutton.Height        = 25;
            savepbutton.ClientEnabled = false;
            //文件显示列表
            listpround.HeaderText         = "图片列表";
            listpround.HeaderStyle.Height = 10;
            listpround.Width = Unit.Percentage(100);
            //girdview
            GridViewDataHyperLinkColumn namecolumn = new GridViewDataHyperLinkColumn();
            GridViewDataTextColumn      sizecolumn = new GridViewDataTextColumn();
            GridViewCommandColumn       operation  = new GridViewCommandColumn();
            namecolumn.Caption             = "文件名";
            namecolumn.Width               = 150;
            namecolumn.FieldName           = "picname";
            sizecolumn.Caption             = "文件大小";
            sizecolumn.Width               = 50;
            sizecolumn.FieldName           = "picsize";
            operation.Caption              = "文件操作";
            operation.Width                = 30;
            operation.DeleteButton.Visible = true;
            operation.DeleteButton.Text    = "删除";
            listgrid.Columns.Add(namecolumn);
            listgrid.Columns.Add(sizecolumn);
            listgrid.Columns.Add(operation);
            listgrid.Settings.ShowColumnHeaders = false;
            List <PicList> piclist = new List <PicList>();
            PicList        newrow  = new PicList();
            newrow.picname = "123.jpg";
            newrow.picsize = "123KB";
            piclist.Add(newrow);
            newrow         = new PicList();
            newrow.picname = "456.jpg";
            newrow.picsize = "456KB";
            piclist.Add(newrow);
            //gridview加入roundpanel
            listgrid.DataSource = piclist;
            listgrid.DataBind();
            listcontent.Controls.Add(listgrid);
            listpround.Controls.Add(listcontent);
            #region 页面构建
            Table pictable = new Table();
            panel.Controls.Add(new LiteralControl("<table width=\"500px\"><tr><td><table cellspacing=\"1\" cellpadding=\"2\"><tr><td colspan=\"3\" width=\"135px\">"));
            panel.Controls.Add(uploadpctrl);
            panel.Controls.Add(new LiteralControl("</td><td width=\"45px\">"));
            panel.Controls.Add(uploadpbutton);
            panel.Controls.Add(new LiteralControl("</td></tr><tr><td colspan=\"4\" width=\"180px\">"));
            panel.Controls.Add(uploadptext);
            panel.Controls.Add(new LiteralControl("</tr><tr><td colspan=\"2\" width=\"90px\">"));
            panel.Controls.Add(previewpbutton);
            panel.Controls.Add(previewpopup);
            panel.Controls.Add(new LiteralControl("</td><td width=\"45px\">"));
            panel.Controls.Add(clippingpbutton);
            panel.Controls.Add(clippingpopup);
            panel.Controls.Add(new LiteralControl("</td><td width=\"45px\">"));
            panel.Controls.Add(clearpbutton);
            panel.Controls.Add(new LiteralControl("</td></tr><tr><td colspan=\"4\" width=\"180px\">"));
            panel.Controls.Add(savepbutton);
            panel.Controls.Add(new LiteralControl("</td></tr></table></td><td  valign=\"top\" width=\"300px\">"));
            panel.Controls.Add(listpround);
            panel.Controls.Add(new LiteralControl("</td></tr></table>"));
            #endregion
            return(panel);
        }
 public void UploadFile(ASPxUploadControl uploadCtrl, DevExpress.Web.FileUploadCompleteEventArgs e, string map)
 {
     UploadFiles upf = new UploadFiles();
     string path = upf.UploadFileDoc(e.UploadedFile.FileName, DocTypeId, uploadCtrl, map);
     e.UploadedFile.SaveAs(Server.MapPath(path + e.UploadedFile.FileName), true);
 }
示例#30
0
 public ASPxPropertyEditorUploadControlProvider(ASPxUploadControl asPxUploadControl, WebPropertyEditor webPropertyEditor)
 {
     _asPxUploadControl = asPxUploadControl;
     _webPropertyEditor = webPropertyEditor;
 }
示例#31
0
        public override System.Web.UI.Control Build()
        {
            base.Build();
            ASPxPanel         panel            = new ASPxPanel();
            ASPxUploadControl upload           = new ASPxUploadControl();
            ASPxButton        uploadbotton     = new ASPxButton();
            ASPxLabel         uploadurl        = new ASPxLabel();
            ASPxButton        clippingbutton   = new ASPxButton();
            ASPxButton        previewbutton    = new ASPxButton();
            ASPxButton        clippingWH       = new ASPxButton();
            ASPxButton        clippingSubmit   = new ASPxButton();
            ASPxButton        clippingCancel   = new ASPxButton();
            ASPxPopupControl  clipping         = new ASPxPopupControl();
            ASPxPopupControl  preview          = new ASPxPopupControl();
            ASPxCallback      callbackpic      = new ASPxCallback();
            ASPxLabel         uploadfinishname = new ASPxLabel();
            ASPxButton        imagedelete      = new ASPxButton();
            ASPxCallback      callbackdelete   = new ASPxCallback();
            ASPxHiddenField   picturehf        = new ASPxHiddenField();

            //定义upload
            upload.ClientInstanceName  = "upload";
            upload.ShowProgressPanel   = true;
            upload.BrowseButton.Text   = "浏览";
            upload.FileUploadComplete += new EventHandler <FileUploadCompleteEventArgs>(uc_FileUploadComplete);
            //upload.ClientSideEvents.FilesUploadComplete = "function(s, e) { Uploader_PicturesUploadComplete(e); }";
            upload.ClientSideEvents.FileUploadComplete = "function(s, e) { Uploader_PictureUploadComplete(e); }";
            upload.ClientSideEvents.FileUploadStart    = "function(s, e) { Uploader_PictureUploadStart(); }";
            upload.ClientSideEvents.TextChanged        = "function(s, e) { PictureUpdateUploadButton(); }";
            upload.ValidationSettings.MaxFileSize      = 4194304;
            string[] fileExtensions = new string[4] {
                ".jpg", ".jpeg", ".jpe", ".gif"
            };
            upload.ValidationSettings.AllowedFileExtensions = fileExtensions;
            //定义上传按钮
            uploadbotton.AutoPostBack           = false;
            uploadbotton.Text                   = "上传";
            uploadbotton.ClientInstanceName     = "uploadpicturebotton";
            uploadbotton.ClientEnabled          = false;
            uploadbotton.ClientSideEvents.Click = "function(s, e) { imagedelete();upload.Upload();}";
            //定义剪裁按钮
            clippingbutton.AutoPostBack           = false;
            clippingbutton.Text                   = "剪裁";
            clippingbutton.ClientInstanceName     = "clippingbutton";
            clippingbutton.ClientEnabled          = false;
            clippingbutton.ClientSideEvents.Click = "function(s, e) { clipping();initialization();}";
            //弹出的剪裁窗口定义
            clipping.CloseAction          = CloseAction.CloseButton;
            clipping.Modal                = true;
            clipping.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
            clipping.PopupVerticalAlign   = PopupVerticalAlign.WindowCenter;
            clipping.ClientInstanceName   = "clippingview";
            clipping.HeaderText           = "图片剪裁";
            clipping.AllowDragging        = true;
            clipping.EnableAnimation      = false;
            clipping.EnableViewState      = false;
            clipping.MinWidth             = 500;
            clipping.MinHeight            = 400;
            clipping.ClientSideEvents.CloseButtonClick = "function(s, e) { destroy();}";
            clipping.ClientSideEvents.Init             = "function(s, e){s.hideBodyScrollWhenModal = false;}";
            //弹出剪裁窗口中的控件定义
            clippingWH.AutoPostBack           = false;
            clippingWH.Text                   = "更改长宽";
            clippingWH.ClientSideEvents.Click = "function(s, e) { clippingWHclick();}";

            clippingSubmit.AutoPostBack           = false;
            clippingSubmit.Text                   = "剪裁";
            clippingSubmit.ClientSideEvents.Click = "function(s, e) { clippingSubmit();}";

            //callback接收剪裁数据
            callbackpic.ClientInstanceName = "callbackpic";
            callbackpic.Callback          += new CallbackEventHandler(OnCallbackComplete);
            callbackpic.ClientSideEvents.CallbackComplete = "function(s, e) { CallbackComplete(e);}";

            clippingCancel.AutoPostBack           = false;
            clippingCancel.Text                   = "取消";
            clippingCancel.ClientSideEvents.Click = "function(s, e) { clippingview.Hide();destroy();}";
            clipping.Controls.Add(new LiteralControl("<table><tr><td>"));
            clipping.Controls.Add(new LiteralControl("<img src='' id='clippingpicture' alt='' />"));
            clipping.Controls.Add(new LiteralControl("</td><td>"));
            clipping.Controls.Add(new LiteralControl("<div style='width:150px;height:150px;overflow:hidden;' id='divsmall'>"));
            clipping.Controls.Add(new LiteralControl("<img src='' id='small' alt='' />"));
            clipping.Controls.Add(new LiteralControl("</div></td></tr></table>"));
            clipping.Controls.Add(new LiteralControl("<br />"));
            clipping.Controls.Add(new LiteralControl("<table><tr><td colspan='6'>可自定义框体长宽:</td>"));
            clipping.Controls.Add(new LiteralControl("<tr><td><label>X1 <input type='text' size='4' id='x1' name='x1' readonly='readonly' /></label></td>"));
            clipping.Controls.Add(new LiteralControl("<td><label>Y1 <input type='text' size='4' id='y1' name='y1' readonly='readonly' /></label></td>"));
            clipping.Controls.Add(new LiteralControl("<td><label>X2 <input type='text' size='4' id='x2' name='x2' readonly='readonly' /></label></td>"));
            clipping.Controls.Add(new LiteralControl("<td><label>Y2 <input type='text' size='4' id='y2' name='y2' readonly='readonly' /></label></td>"));
            clipping.Controls.Add(new LiteralControl("<td><label>W <input type='text' size='4' id='w' name='w' /></label></td>"));
            clipping.Controls.Add(new LiteralControl("<td><label>H <input type='text' size='4' id='h' name='h' /></label></td></tr>"));
            clipping.Controls.Add(new LiteralControl("<tr><td colspan='4'></td>"));
            clipping.Controls.Add(new LiteralControl("<td colspan='2' align='middle'>"));
            clipping.Controls.Add(clippingWH);
            clipping.Controls.Add(new LiteralControl("</td></tr>"));
            clipping.Controls.Add(new LiteralControl("<tr><td>"));
            clipping.Controls.Add(clippingSubmit);
            clipping.Controls.Add(new LiteralControl("</td>"));
            clipping.Controls.Add(new LiteralControl("<td>"));
            clipping.Controls.Add(clippingCancel);
            clipping.Controls.Add(new LiteralControl("</td>"));
            clipping.Controls.Add(new LiteralControl("<td>"));
            clipping.Controls.Add(new LiteralControl("<input type='checkbox' id='ar_lock'/><label for='ar_lock'>比例固定</label>"));
            clipping.Controls.Add(new LiteralControl("</td>"));
            clipping.Controls.Add(new LiteralControl("<td colspan='5'></td></tr></table>"));
            //定义Label
            uploadurl.Text = "";//文件名
            uploadurl.ClientInstanceName = "uploadurl";
            //定义预览按钮
            previewbutton.AutoPostBack           = false;
            previewbutton.Text                   = "预览";
            previewbutton.ClientInstanceName     = "previewbutton";
            previewbutton.ClientEnabled          = false;
            previewbutton.ClientSideEvents.Click = "function(s, e) { preview(); }";
            //弹出的预览窗口定义
            preview.CloseAction          = CloseAction.CloseButton;
            preview.Modal                = true;
            preview.PopupHorizontalAlign = PopupHorizontalAlign.WindowCenter;
            preview.PopupVerticalAlign   = PopupVerticalAlign.WindowCenter;
            preview.ClientInstanceName   = "previewview";
            preview.HeaderText           = "图片预览";
            preview.AllowDragging        = true;
            preview.EnableAnimation      = false;
            preview.EnableViewState      = false;
            preview.Controls.Add(new LiteralControl("<img id='previewpicture' alt='' src=''"));
            preview.ClientSideEvents.Init = "function(s, e){s.hideBodyScrollWhenModal = false;}";
            //定义上传后保存的文件名。uploadfinishname
            uploadfinishname.Text = "";
            uploadfinishname.ClientInstanceName = "uploadfinishname";
            //上传后,删除按钮
            imagedelete.AutoPostBack           = false;
            imagedelete.Text                   = "删除";
            imagedelete.ClientInstanceName     = "imagedeletebutton";
            imagedelete.ClientEnabled          = false;
            imagedelete.ClientSideEvents.Click = "function(s, e) { imagedelete(); }";
            //点击删除按钮callback服务器删除对应图片
            callbackdelete.ClientInstanceName = "callbackdeleteimg";
            callbackdelete.Callback          += new CallbackEventHandler(OnCallbackDeleteImg);
            //隐藏控件保存图片地址
            picturehf.ClientInstanceName = "picturehf";

            panel.Controls.Add(new LiteralControl("<table><tr><td>"));
            panel.Controls.Add(upload);
            panel.Controls.Add(new LiteralControl("</td><td>"));
            panel.Controls.Add(uploadbotton);
            panel.Controls.Add(new LiteralControl("</td></tr><tr><td>"));
            panel.Controls.Add(uploadurl);
            panel.Controls.Add(new LiteralControl("</td><td>"));
            panel.Controls.Add(clippingbutton);
            panel.Controls.Add(clipping);
            panel.Controls.Add(new LiteralControl("</td></tr><tr><td>"));
            panel.Controls.Add(uploadfinishname);
            panel.Controls.Add(new LiteralControl("</td><td>"));
            panel.Controls.Add(imagedelete);
            panel.Controls.Add(previewbutton);
            panel.Controls.Add(preview);
            panel.Controls.Add(new LiteralControl("</td></tr></table>"));
            panel.Controls.Add(callbackpic);
            panel.Controls.Add(callbackdelete);
            panel.Controls.Add(picturehf);
            return(panel);
        }
示例#32
0
        private void control_UploadControlCreated(object sender, EventArgs e)
        {
            ASPxUploadControl uploadControl = ((FileDataEdit)sender).UploadControl;

            uploadControl.ValidationSettings.AllowedFileExtensions = new String[] { ".zip" };
        }