Avoiding postbacks

  •  08-12-2010, 1:10 AM

    Avoiding postbacks

    Hi
     
    We're currently evaluating the ajaxuploader for our application.

    We want the uploader to do it's thing BUT not do a postback -- we'll then do an ajax postback so that we can update some info and put the file into a database without doing a postback.
     
     I've put in script as follows:-
     
         function CuteWebUI_AjaxUploader_OnProgress(enable, filename, begintime, uploadedsize, totalsize) {
             return false;
         }
     
     but what we're finding is that it still posts back.
     
    I've put in a lot of the javascript global functions and note that it seems to posted back after one time through Progress but that might just be a coincedence.
     
    I'm guessing I'm doing something wrong but cannot see why.
     
    My markup looks like:
     
     
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
    <%@ Register Assembly="CuteWebUI.AjaxUploader" Namespace="CuteWebUI" TagPrefix="CuteWebUI" %>
    <!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>Untitled Page</title>
        <script type="text/javascript">
          function pageLoad() {
          }
        
         function $() {
             var aElements = new Array();
             var nLength = arguments.length;
             for (var i = 0; i < nLength; i++) {
                 var oElement = arguments[i];
                 if (typeof oElement == 'string') {
                     oElement = document.getElementById(oElement);
                 }
                 if (nLength == 1) {
                     return oElement;
                 }
                 aElements.push(oElement);
             }
             return aElements;
         }

         function HideDiv(form_element) {
             if ($(form_element) == null) {
                 alert(form_element);
             }
             else {
                 $(form_element).style.display = 'none';
             }
         }

         function ShowDiv(form_element) {
             if ($(form_element) == null) {
                 alert(form_element);
             }
             else {
                 $(form_element).style.display = '';
             }
         }

         function CuteWebUI_AjaxUploader_OnStart() {
             alert('CuteWebUI_AjaxUploader_OnStart');
             
         }

         function CuteWebUI_AjaxUploader_OnStop() {
             alert('CuteWebUI_AjaxUploader_OnStop');
         }

         function CuteWebUI_AjaxUploader_OnQueueUI(list) {
             ShowDiv('CuteWebUI_AjaxUploader_OnQueueUI');
             return false;
         }

         function CuteWebUI_AjaxUploader_OnProgress(enable, filename, begintime, uploadedsize, totalsize) {
             ShowDiv('CuteWebUI_AjaxUploader_OnProgress');
             return false;
         }

         function CuteWebUI_AjaxUploader_OnTaskComplete(obj) {
             var sReturn = 'false';
             alert("Complete : " + obj.FileName + " : " + obj.FileGuid);
             try {
                 alert('put the call to ajax postback here!');
             }
             catch (e) {
                 alert(e);
                 alert('problem');
             }
         }

         function CuteWebUI_AjaxUploader_OnPostback() {
             alert('CuteWebUI_AjaxUploader_OnPostback');
             return false;
         }    
          
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <a href="#" id="btnUpload">Choose File</a>
            <a href="#" id="btnCancel">Cancel</a>
            <img id="ProgressBar" style="display:none;" src="images/smactivity.gif" alt="" />
            <CuteWebUI:Uploader runat="server"
                ID="Uploader1"
                CancelButtonID="btnCancel"
                InsertButtonID="btnUpload">
                <ValidateOption MaxSizeKB="100" AllowedFileExtensions="jpg,png,gif"/>
            </CuteWebUI:Uploader>
        </div>
        </form>
    </body>
    </html>
    My code behinds at this point doesnt do much apart from this
     
    public partial class Default3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // Check if we get here
            }
        }
    }
     
    Any ideas?
     
    James Beauchamp
View Complete Thread