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

Register File Selection to a Image

3 Answers 29 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 20 Jan 2011, 11:59 AM
Hi

I am attempting to register the RadUpload control to an image button event.

Currently, I have the image button in place and I have created a separate page with the RadUpload control registered and I will be using an iframe to render in the background without being shown to the user.

I want the image button to open the actual file selection (browse button) from the image press, allow the user to select a file and pass this back to the originating page.

Is there a JavaScript method I can access that will allow me to do this?

Currently I have (Ignore the implicit drill down to the control, I am going to create a loop to find the "ruButton ruBrowse" class) :
$find('cRadUpload').get_element().getElementsByTagName('ul')[0].getElementsByTagName('li')[0].getElementsByTagName('input')[0].click();

But the image button does nothing when clicked...

Regards,
Jonathan

3 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 20 Jan 2011, 02:17 PM
Hello Jonathan,

I tried this and it works:

// get RadUpload control
var fileUpload = $find("<%=RadUpload1.ClientID %>");
// ger file inputs
var inputs = fileUpload.getFileInputs();
// click first file input
inputs[0].click();

I hope that helps.
0
Jonathan
Top achievements
Rank 1
answered on 20 Jan 2011, 03:48 PM
Hi,

I am getting an Access is Denied error when trying to submit the form to the server:

function Update()
{
     window.parent.Update(document.getElementById('upload2').value, _labelId);
     //Access is Denied error occurs on the below line
     document.getElementById('PostBackButton').click();
}

0
Dimitar Terziev
Telerik team
answered on 21 Jan 2011, 09:17 AM
Hello Jonathan,

In general what you are trying to achieve is not allowed except in some versions of IE. Probably what's Cori could achieve it , but this is not supported in other browsers like Mozilla and etc. Also this is not very safe from security side to be able to open the browse for file window through javascript.
There is no workaround for this scenario, that we could provide.


Greetings,
Dimitar Terziev
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.
Tags
Upload (Obsolete)
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Jonathan
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Share this question
or