Throwing errors in Custom Adapters

Nov 26, 2008 at 3:33 PM
I always wind up finding myself needing strange situations using this control... Maybe it's because I just love it so much.

My latest weirdness is that I'd like to use some additional logic inside a custom adapter. For instance, if a file already exists, I'd like to mark that particular file as a failure, and then retrieve that there was a problem with that file in my FileReceived handler. So the flow would be something like this

public override void ProcessFile(HttpPostedFile file)
        do stuff

[codebehind for page]
protected void FileReceived(object sender, EventArgs e)
       handle stuff this way
        process like normal.

Any thoughts? Thanks in advance!

Nov 26, 2008 at 6:02 PM
Just read the documentation :)
Dec 1, 2008 at 7:52 PM
How can I know the index of the file being processed in a batch? For example, an old post here ( refers to a .index property, but this no longer seems to be the case.

Also, how can I throw a status error from my custom upload adapter? I understand the client-side portion (for the most part) but I can't figure out how to create my own error conditions in the upload adapter.

So for example, I want to reject a file server-side based on the processing I'm doing in the custom adapter. I want to send that error to the javascript, and I want to count and reference the files so I can have some useful messages (x of y photos successfully updated), etc.

Thanks as always.
Dec 1, 2008 at 8:16 PM
Ok, so I think I can get an error thrown this way, but can I pass the text across to the javascript, or do I only know that there's been *an* error?

...inside the adapter:
if (!fileexists.Exists)
    file.SaveAs(String.Concat(fullpath, Path.DirectorySeparatorChar, file.FileName));
    throw new Exception("that there file done already be there.");

Still wondering about the indexing, though... Thanks!
Dec 1, 2008 at 8:31 PM
Edited Dec 1, 2008 at 8:33 PM
For the error why don't you do that:

I am not sure why you would need to know the index of the file? You have it's name. You can get the index as:

function FileStateChanged(uploader, file, httpStatus, isLast){
    Flajaxian.fileStateChanged(uploader, file, httpStatus, isLast);
    if(file.state > Flajaxian.File_Uploading){
        var index = -1;
        for(var i = 0; i < uploader.get_filesList().length; i++){
              if(uploader.get_filesList()[i].id =={
                   index = i; break;
<div id="MyDiv"></div>
<fjx:FileUploader JsFunc_FileStateChanged="FileStateChanged" runat="server" >
        <fjx:FileSaverAdapter Runat="server" FolderName="UploadFolder" />
Dec 1, 2008 at 8:33 PM
Ah ok you are asking if you can transfer strings. No, you have to aggree on code=string pairs, then you can initiate them on the client. But transfering big strings back and forth is not a very good idea
Dec 3, 2008 at 4:59 PM
Your Javascript actually led to exactly what I need - the property! I was not aware that property existed, and that's what I needed. Thank you. Maybe we can get an update to the documentation that lists all the client-side properties of the objects?

As for the error stuff, is the HTTP context able to be modified within an upload adapter? I'm content at this point to just throw a generic error and be  done with it, but perhaps in the future it would be nice to identify specific errors by doing as outlined in the docs, except from within the upload adapter itself rather than the code-behind.

Thanks again.
Dec 4, 2008 at 3:05 AM
I have updated the documentation at