Hi,
Please try the example below.
- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="UploaderExample.aspx.cs" Inherits="UploaderExample" %>
-
- <%@ Register Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" TagPrefix="CuteWebUI" %>
- <!DOCTYPE html>
-
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title>example</title>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <CuteWebUI:UploadAttachments runat="server" ManualStartUpload="true" ID="Uploader1"
- InsertText="Browse Files (Max 1M)" OnFileUploaded="Uploader1_FileUploaded">
- </CuteWebUI:UploadAttachments>
-
- </div>
- <p>
- <asp:Button runat="server" ID="SubmitButton" Text="Submit" OnClientClick="return submitbutton_click()" />
- </p>
- </form>
- </body>
- </html>
- <script type="text/javascript">
-
- function submitbutton_click() {
- var submitbutton = document.getElementById('<%=SubmitButton.ClientID %>');
- var uploadobj = document.getElementById('<%=Uploader1.ClientID %>');
- if (!window.filesuploaded) {
- if (uploadobj.getqueuecount() > 0) {
-
- uploadobj.startupload();
- }
- else {
- var uploadedcount = parseInt(submitbutton.getAttribute("itemcount")) || 0;
- if (uploadedcount > 0) {
- return true;
- }
- alert("Please browse files for uploading");
- }
- return false;
- }
- window.filesuploaded = false;
- return true;
- }
- function CuteWebUI_AjaxUploader_OnPostback() {
- window.filesuploaded = true;
- var submitbutton = document.getElementById('<%=SubmitButton.ClientID %>');
- submitbutton.click();
- return false;
- }
- </script>
.cs file
- using System;
- using System.Collections.Generic;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
-
- public partial class UploaderExample : System.Web.UI.Page
- {
- protected void Uploader1_FileUploaded(object sender, CuteWebUI.UploaderEventArgs args)
- {
- byte[] data = new byte[args.FileSize];
-
- using (System.IO.Stream stream = args.OpenStream())
- {
-
- }
- }
- }
Regards,
Ken