
In radupload control, when press add button , just fileinput box only appear... when click each time add button in radupload, I want two textbox also....can anyone help me?..thanks
27 Answers, 1 is accepted

I tried following code snippet in order to add two upload textboxes when clicking the Add button.
JavaScript:
<script type="text/javascript"> |
var check = 0; |
function OnClientAdded(sender, args) { |
if (args.get_rowIndex() != 0 && check == 0) { |
check = 1; |
sender.addFileInput(); |
} |
else { |
check = 0; |
} |
} |
</script> |
-Shinu.

thanks...I used below script..
function addTitle(radUpload, args)
{
var curLiEl = args.get_row();
var firstInput = curLiEl.getElementsByTagName("input")[0];
//Create a simple HTML template.
var table = document.createElement("table");
table.className =
'AdditionalInputs';
//A new row for a Title field
row = table.insertRow(-1);
cell = row.insertCell(-1);
var input = CreateInput("Title", "text");
input.className =
"TextField";
input.id = input.name = radUpload.getID(input.name);
var label = CreateLabel("Name",input.id);
cell.appendChild(label);
cell = row.insertCell(-1);
cell.appendChild(input);
//A new row for a Description field
row = table.insertRow(-1);
cell = row.insertCell(-1);
input = CreateInput(
"Desc", "text");
input.className =
"TextField";
input.id = input.name = radUpload.getID(input.name);
label = CreateLabel(
"Type of the Document",input.id);
cell.appendChild(label);
cell = row.insertCell(-1);
cell.appendChild(input);
//Add a File label in front of the file input
var fileInputSpan = curLiEl.getElementsByTagName("span")[0];
var firstNode = curLiEl.childNodes[0];
label = CreateLabel(
"File",radUpload.getID());
curLiEl.insertBefore(label, firstNode);
curLiEl.insertBefore(table, label);
}
function CreateLabel(text, associatedControlId)
{
var label = document.createElement("label");
label.innerHTML = text;
label.setAttribute(
"for", associatedControlId);
label.style.fontSize = 12;
return label;
}
function CreateInput(inputName, type)
{
var input = document.createElement("input");
input.type = type;
input.name = inputName;
return input;
}
how i can retrive these description & title textbox value to database....please help me?
On the server, you can access the additional fields in the following way:
protected void Button1_Click(object sender, EventArgs e)
{
foreach (UploadedFile f in RadUpload1.UploadedFiles)
{
string fileName = f.GetName();
string title = f.GetFieldValue("Title");
string desc = f.GetIsFieldChecked("Desc");
// Proceed with your database insertion
}
}
Since you have the values in the variables title and desc you can proceed with the database insertion. The insertion depends on what access layer you use.
Best wishes,
Genady Sergeev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

thank you! I have another one issue....I have create two textbox using above script...I want these two textbox and rad upload in a single row....can anyone give sample code?
thanks!
I have prepared example for you that shows hot to achieve the desired functionality. I have used jQuery instead of pure JavaScript with led to dramatically reduced code, just 3 lines of code. You can find the sample as an attachment.
Regards,
Genady Sergeev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

thank u very much...I want label field also....how include label field in script?
thX...
You can use the following modified code:
function
onClientAddedHandler(sender, args)
{
var
idAddField = sender.getID(
"additional"
);
$(
".ruInputs li[class='']:last span"
)
.before($(
"<label>Type of the Document</label>"
).attr(
"for"
, idAddField))
.before($(
"<input type='text' />"
).attr(
"id"
, idAddField ).attr(
"name"
, idAddField));
}
All the best,
Genady Sergeev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.



I want to add textboxes, just like the upload does, but , not for uploading files. I just want to add textboxes,that will be bound to the database. How best can I achieve this.
Regards,

I guess you want to add textboxes dynamically on clicking a button. Here is the code snippet which I tried for accomplishing the scenario.
ASPX:
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"> |
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> |
</telerik:RadAjaxPanel> |
CS:
protected void Page_Load(object sender, EventArgs e) |
{ |
if (IsPostBack) |
{ |
if (ViewState["Index"] != null) |
{ |
int index = Convert.ToInt32(ViewState["Index"]); |
if (getPostBackControlName() == "Button1") |
{ |
for (int i = 0; i <= index; i++) |
{ |
TextBox txtbx = new TextBox(); |
txtbx.ID = "TextBox" + i; |
RadAjaxPanel1.Controls.Add(txtbx); |
} |
} |
else |
{ |
for (int i = 1; i <= index; i++) |
{ |
TextBox txtbx = new TextBox(); |
txtbx.ID = "TextBox" + i; |
RadAjaxPanel1.Controls.Add(txtbx); |
} |
} |
} |
} |
else |
{ |
ViewState["Index"] = 0; |
} |
} |
protected void Button1_Click(object sender, EventArgs e) |
{ |
if (ViewState["Index"] == null) |
{ |
TextBox txtbx = new TextBox(); |
txtbx.ID = "TextBox1"; |
RadAjaxPanel1.Controls.Add(txtbx); |
} |
ViewState["Index"] = Convert.ToInt32(ViewState["Index"]) + 1; |
} |
private string getPostBackControlName() |
{ |
Control control = null; |
string ctrlname = Page.Request.Params["__EVENTTARGET"]; |
if (ctrlname != null && ctrlname != String.Empty) |
{ |
control = Page.FindControl(ctrlname); |
} |
// if __EVENTTARGET is null, the control is a button type and we need to |
// iterate over the form collection to find it |
else |
{ |
string ctrlStr = String.Empty; |
Control c = null; |
foreach (string ctl in Page.Request.Form) |
{ |
if (ctl.EndsWith(".x") || ctl.EndsWith(".y")) |
{ |
ctrlStr = ctl.Substring(0, ctl.Length - 2); |
c = Page.FindControl(ctrlStr); |
} |
else |
{ |
c = Page.FindControl(ctl); |
} |
if (c is System.Web.UI.WebControls.Button || c is System.Web.UI.WebControls.ImageButton) |
{ |
control = c; |
break; |
} |
} |
} |
return control.ID; |
} |
Hope this helps,
Shinu.
Nikesh Bhagat, concern using RadioButtons instead of CheckBoxes. They suit your case far more good. You can find out how to do it in this thread.
Sebastien Desemberg, I am not sure what you are trying to achieve. The code that I have posted shows how to add textboxes to RadUpload in order to have additional fields containing information regarding the files uploaded.
In order to have TextBoxes bound to a database fields, you need to use a DataBound control. There are other ways as well but they are more complicate. Choosing the control that suits your needs best depends on how much information you need to extract. If you supply us with more information regarding your scenario we will provide you with tips and suggestions on how to achieve your task.
Regards
Genady Sergeevthe Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.


I took a look at the thread you recommended, but it's not quite what i'm looking for. The thread describes how to create a radiobutton list for each addtional RadUpload input element so that you can only select one or the other radiobutton option, but for each input field. In other words, more than one radiobutton can be selected if there is more than one input field added by the user...
I want to be able to add a radiobutton list to the entire input field collection so that you can only select one radiobutton in total..
For Example: The user adds two input fields: input1 and input2. Each input has a radiobutton attached to it, but the user is only able to select either input1 or input2, leaving one or the other unselected... and leaving me with only the value of the one and only selected radiobutton.. I would need to allow the user to clear the radiobutton list so no radiobutton is selected and I'm unsure of how I would iterate through the UploadedFiles in order to retrieve the value of a radiobutton if it is selected...
any ideas?
Nik
I have prepared sample project that demonstrates the mentioned functionality:
1) Each row has it's own radio button
2) Only one radio button can be selected at a time
3) You can obtain its value from the server the standard way. All radio buttons that are not selected will return NULL as their value. The selected one will return the value that you have set on the client.
You can find the project as an attachment.
Best wishes,Genady Sergeev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

This is EXACTLY what I'm looking for... But when I plunked code into my project I got this error:
Assembly 'Telerik.Web.UI, Version=2008.1.515.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4' does not contain a Web resource with name 'Telerik.Web.UI.Common.jQuery.js'.
I understand the project reference jQuery... but I'm not sure how to implement this properly...
regards,
Nik
Your version of the controls does not have jQuery, therefore the script references can't find it and error is thrown. Either upgrade to a newer version of the controls or add manually jQuery to your page. You can download jQuery from here.
All the best,
Genady Sergeev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.

So I've manually implemented jquery on my page as follows:
<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
But i'm getting an 'object expected' error starting from the following line as indicated by IE8:
var $radioButton = $("<input type='radio' />").attr("name", idAddField).val("Value1");
Any ideas?

bharti ten, I have attached sample project that demonstrates how to validate the additional file inputs.
Nikesh Bhagat, why are you insert jQuery manually? jQuery is used internally by almost all RadControls, therefore if you have, say RadUpload, on your page you automatically have jQuery as well. You can access the jQuery object using the following syntax:
var
jQuery = $telerik.$;
Using the jQuery version that ships with RadControls I am unable to reproduce the issue that you experience. Can you open a support ticket and attach sample project that fails on your side? This will allow to track and debug the issue for you.
All the best,
Genady Sergeev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

Assembly 'Telerik.Web.UI, Version=2008.1.515.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4' does not contain a Web resource with name 'Telerik.Web.UI.Common.jQuery.js'.
You informed me that this was because my version of the controls do not include jQuery and instructed me to implement it manually since I am unwilling to update my controls...

Please replace
var
descValue = $get(
"RadUpload1description"
+ i).value
with
var
descValue = $get(
'<%= RadUpload1.ClientID %>'
+
'description'
+ i).value;
Does the issue persist?
Nikesh Bhagat, could you please open a support ticket and send us sample project that reproduces the issue. This will allow us to find out what is going wrong on your side.
All the best,
Genady Sergeev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.


I am using this code to implement a textbox to feed some title for every uploaded file but the problem I am facing is :
Assembly 'Telerik.Web.UI, Version=2008.3.1016.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4' does not contain a Web resource with name 'Telerik.Web.UI.Common.jQueryInclude.js'.
I also tried to download this jquery from given link but not found any such query.
please help.

i have a situation here,
I want to upload multiple files / Documents
i am using RadUpload
each file has specific name, which is already exist in database (Table Name : DocumentNames)
i want to show these documents in the radiobuttonlist, which should be attached with RadUpload
when user click on (Add) button of radupload, RadioButtonList should appear without the last selected document/item.
can anybody help me out
When it is not possible to use required field validator, because the number of the validated inputs is unknown.
My suggestion about your required field validator for RadUpload without jQuery is: when an input is added on the client, OnClientAdded event is fired. Get with args.get_fileInputField().id method all IDs and save them into array. Before page submit check the input values. Here is my sample code:
<
div
>
<
telerik:RadScriptManager
runat
=
"server"
ID
=
"RadScriptManager"
></
telerik:RadScriptManager
>
<
telerik:RadUpload
runat
=
"server"
ID
=
"RadUpload"
MaxFileSize
=
"500000000"
OnClientAdded
=
"onClientAdded"
></
telerik:RadUpload
>
<
input
type
=
"button"
onclick
=
"onButtonClick()"
/>
</
div
>
</
form
>
<
script
type
=
"text/javascript"
>
var inputs = new Array();
function onClientAdded(sender, args){
inputs.push(args.get_fileInputField().id);
}
function onButtonClick(){
debugger;
for(var i=0; i<
inputs.length
;i++){
var
input
=
document
.getElementById(inputs[i]);
alert(input.value);
}
// if all input values are different than "" , then submit the page
// document.form1.submit();
}
</script>
Regarding Mona's post, the issue is probably caused because you are using old version of our controls.
To avoid the thread to become inconsistent Mona, adnan please open new support tickets for your issues.
Regards,
Peter Filipov
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.