This is a migrated thread and some comments may be shown as answers.

Best way to make sure a description field is added?

1 Answer 52 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
danparker276
Top achievements
Rank 2
danparker276 asked on 09 Apr 2013, 02:24 AM
I want to make sure someone puts in a Description before they upload a file.  Not like the example where the description is put in after. I can do it with manual upload like:
function startManualUpload() {
    var tb = $find('<%=tbFileDesc.ClientID%>');
    var tbtxt = tb._text.length;
    if (tbtxt == 0) {
 //write some error
    }
    else {
        var upload = $find('<%=radUpAssoc.ClientID%>');
        upload.startUpload();
    }
 
}

But then I want to add the description to my AsyncUploadConfiguration.  I'm setting this on the server side though.
How can I add on to my AsyncUploadConfiguration from here?  I'm not so good at javascript so maybe this is easy.

I guess I could do a Response.write with the startmanualUpload function, but that was acting a bit strange.

1 Answer, 1 is accepted

Sort by
0
Hristo Valyavicharski
Telerik team
answered on 11 Apr 2013, 03:17 PM
Hi Dan,

AsyncUploadConfiguration is used to pass custom information from the page to the handler. It exposes these properties. AsyncUploadConfiguration cannot be modified on the client. To prevent file uploading if the Description field is empty you can cancel uploading:
function OnClientFileUploading(sender, args) {
    var tb = $find('<%=tbFileDesc.ClientID%>');
    var tbtxt = tb._text.length;
    if (tbtxt == 0) {
        //cancel file uploading
        args.set_cancel(true);
        //write some error
        alert('Enter description');
    }
}


Regards,
Hristo Valyavicharski
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
AsyncUpload
Asked by
danparker276
Top achievements
Rank 2
Answers by
Hristo Valyavicharski
Telerik team
Share this question
or