AsyncUpload can't access addtional field on server side

2 posts, 1 answers
  1. mohamed
    mohamed avatar
    4 posts
    Member since:
    Mar 2011

    Posted 16 Feb 2013 Link to this post

    i can't access the additional fields server side :( i use telerik 2012.3)

    i follow the following link :

    http://demos.telerik.com/aspnet-ajax/asyncupload/examples/additionalfields/defaultcs.aspx

    The script is:

    function onClientFileUploaded(radAsyncUpload, args) {
        var row = args.get_row(),
            inputName = radAsyncUpload.getAdditionalFieldID("TextBox"),
            inputType = "text",
            inputID = inputName,
            input = createInput(inputType, "Title", "Title"),
            label = createLabel(inputID),
            br = document.createElement("br");
     
        row.appendChild(br);
        row.appendChild(input);
        row.appendChild(label);
     
    }
     
    function createInput(inputType, inputID, inputName) {
        var input = document.createElement("input");
     
        input.setAttribute("type", inputType);
        input.setAttribute("id", inputID);
        input.setAttribute("name", inputName);
     
        return input;
    }
     
    function createLabel(forArrt) {
        var label = document.createElement("label");
     
        label.setAttribute("for", forArrt);
        label.innerHTML = "info: ";
     
        return label;
    }
    My .aspx :

    <telerik:RadAsyncUpload runat="server" ID="rada_attach" OnClientFileUploaded="onClientFileUploaded"
      MultipleFileSelection="Disabled" InitialFileInputsCount="1" MaxFileInputsCount="1"
      Width="100%" />

    My .cs :

    foreach (UploadedFile UF in rada_attach.UploadedFiles)
                   {
                       OBJ.File_name = UF.GetFieldValue("Title");//always null
                   }
  2. Answer
    Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 21 Feb 2013 Link to this post

    Hello Mohamed,

    Try to modify your JavaScript code as follows:
    function onClientFileUploaded(radAsyncUpload, args) {
        var row = args.get_row(),
            inputName = radAsyncUpload.getAdditionalFieldID("Title"),
            inputType = "text",
            inputID = inputName,
            //input = createInput(inputType, "Title", "Title"),
            input = createInput(inputType, inputID, inputName),
            label = createLabel(inputID),
            br = document.createElement( "br" );
     
        row.appendChild(br);
        row.appendChild(input);
        row.appendChild(label);
    }

    This change was needed because to find the value of custom filed the GetFieldValue() method internally needs the correct InputName, returned by radAsyncUpload.getAdditionalFieldID("Title"). This allows the control to know where to look for this custom filed, for example if you have multiple uploaded files you will have multiple custom fields. Please test it and let me know if it resolves the issue.

    All the best,
    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