Best way to make sure a description field is added?

2 posts, 0 answers
  1. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 08 Apr 2013 Link to this post

    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.
  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 11 Apr 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top