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

AsyncUpload can't access addtional field on server side

1 Answer 70 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
mohamed
Top achievements
Rank 1
mohamed asked on 16 Feb 2013, 03:40 PM
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
               }

1 Answer, 1 is accepted

Sort by
0
Accepted
Hristo Valyavicharski
Telerik team
answered on 21 Feb 2013, 09:50 AM
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.
Tags
AsyncUpload
Asked by
mohamed
Top achievements
Rank 1
Answers by
Hristo Valyavicharski
Telerik team
Share this question
or