Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the value of the textbox which created dynamically with the Raduploader in code behind?

I use the AsyncUpload


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

function onClientFileUploaded(radAsyncUpload, args) {
    var row = args.get_row(),
        inputName = radAsyncUpload.getAdditionalFieldID("TextBox"),
        inputType = "text",
        inputID = inputName,
        input = createInput(inputType, inputID, inputName),
        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;
}

I want to access the textbox (which created dynamically) in .cs.

How to do that ?


The Full Answer :

var $ = $telerik.$;

function onClientFileUploaded(radAsyncUpload, args) {
    var $row = $(args.get_row());
    var inputName = radAsyncUpload.getID("TextBox");
    var inputType = "text";
    var inputID = inputName;
    var input = createInput(inputType, inputID, inputName);
    var label = createLabel(inputID);
    $row.append("<br/>");
    $row.append(label);
    $row.append(input);
}

function createInput(inputType, inputID, inputName) {
    var input = '<input type="' + inputType + '" id="' + inputID + '" name="' + inputName + '" />';
    return input;
}

function createLabel(forArrt) {
    var label = '<label for=' + forArrt + '>info: </label>';
    return label;
}

   foreach (UploadedFile UF in rada_attach.UploadedFiles)
                {
                    if (UF.GetFieldValue("TextBox") != null)
                    {
                        OBJ.File_name = UF.GetFieldValue("TextBox");
                    }
                    else
                    {
                        OBJ.File_name = UF.GetName();
                    }
like image 478
Anyname Donotcare Avatar asked Oct 05 '22 00:10

Anyname Donotcare


1 Answers

In my opinion documentation is well clear. Check the Description tab on page you refer on. You can access value of dynamic textboxes with code below on postback:

if (rada_attach.UploadedFiles.Count > 0) {
    for (var index = 0; index < rada_attach.UploadedFiles.Count; ++index) {
        var textBoxValue = rada_attach.UploadedFiles[index].GetFieldValue("TextBox");
    }
}

BTW, this scenario is well-dcoumented here: Adding Information to Uploaded Files

like image 56
Yuriy Rozhovetskiy Avatar answered Oct 13 '22 10:10

Yuriy Rozhovetskiy