SlickUpload
Welcome Guest Search | Active Topics | Log In | Register

Selective SlickUpload Processing? Options
chrisajohn
#1 Posted : Tuesday, December 01, 2009 12:08:42 PM
Rank: Newbie

Groups: Registered

Joined: 11/10/2009
Posts: 8

Good day.

On many of our pages we with have an asp button with an "OnClientClick" function like this:

<asp:Button runat="server" id="btnDelete" OnClientClick="return confirm("Are you sure?");" />

What we are seeing is the following when we click the Delete button:

  1. OnClientClick js is run.
  2. SlickUpload stuff is running.  No progress display, but I can tell its not a "normal" postback.
  3. OnClientclick js is run again.
  4. btnDelete processing commences.

The end result is that the code works, but the OnClientClick stuff is being run twice which as you can imagine would be confusing for end-users.

What I suspect is happening is that the button "OnClientClick" stuff is being run, then the slick upload does its thing, then it reclicks the button, which fires the "OnClientClick" again.

Is there a way to only have the slickupload stuff run when a certain button is clicked?  One other note is that due to how we are using the product, we would rather not place our code in the "OnUploadComplete" method.

Thanks for your help.

Axosoft
#2 Posted : Tuesday, December 01, 2009 8:37:51 PM
Rank: Administration


Groups: Administrators

Joined: 7/7/2005
Posts: 1,586
Location: Scottsdale, AZ

SlickUpload automatically processes on each postback by default. It won't show the progress display if no files were selected, but it will still process. To turn this off and kick off the upload only when you want it:

 - Set the AutoUploadOnPostBack="false" attribute on the SlickUpload control.

 - Add the following javascript on the page (replacing SlickUpload1 with whatever the ID of your control is):

 

function startUpload()
{
     kw.get("<%= SlickUpload1.ClientID %>").submit();
}

 - To trigger the upload, call the startUpload function. You'll need to append ;return false; to disable ASP.NET's default postback handling like this:

 

OnClientClick="startUpload();return false;"

You don't have to use the OnUploadComplete event to handle uploads -- on any upload request, you can access the upload status (including the list of files that were uploaded) via the UploadStatus property.

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.