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

Create a Dedicated Submit Button for RAD Upload

5 Answers 171 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Hassan Yasir
Top achievements
Rank 1
Hassan Yasir asked on 23 Apr 2010, 09:51 PM
As mentioned in Telerik Documentation, it's upload control re-acts on postback. Here some users are concerned, that RAD Upload control fires its submit event, when they click to other button or any control which postback on the web form.

Related to this, Telerik online documentation also has got a solution (How to Prevent Upload). After revising those codes, I have modified it little and written codes in a way that users can easily achieve the target.

Javascript:
    <script type="text/javascript"
 
        function onClientSubmitting(progressManager, args) { 
            var eventTarget = document.getElementById('__EVENTTARGET'); 
            if (eventTarget.value == '<%= ButtonUpload.UniqueID %>') { } else { 
            var upload = $find("<%= RadUpload1.ClientID %>"); 
            var fileInputs = upload.getFileInputs(); 
            for (var i = 0; i < fileInputs.length; i++) { 
                upload.clearFileInputAt(i); 
            } 
            } 
        } 
         
    </script> 
Note: ButtonUpload is a LinkButton; Upload must be start when the ButtonUpload is fired.

In the .aspx
  <telerik:RadProgressManager id="Radprogressmanager1" runat="server" OnClientSubmitting = "onClientSubmitting" /> 
    <telerik:RadUpload ID="RadUpload1" runat="server" TargetFolder="uploads"  
        ControlObjectsVisibility="None" Height="25px" MaxFileInputsCount="1" Width="214px"  
       > 
    </telerik:RadUpload> 
    <telerik:RadProgressArea ID="RadProgressArea1" runat="server" Language=""  
        DisplayCancelButton="True"
<Localization Uploaded="Uploaded"></Localization> 
    </telerik:RadProgressArea> 
  
    <br /> 
  <asp:LinkButton runat="server" id="ButtonUpload" text="Upload" /> 
Note: Make sure to provide the onClientSubmitting method to RadProgressManager

Excluding to this topic: Some users very often complain that RadProgressArea does not work while uploading. And regarding to my experience it happens when your Application's Trust level is medium.

You can adjust it by writing these codes in web.config:
<system.web> 
    <trust level="Full" /> 
</system.web> 

Thank You

Regards,
Tekie



5 Answers, 1 is accepted

Sort by
0
Majid Darab
Top achievements
Rank 1
answered on 24 May 2010, 08:40 AM
Hi My Dear Friend :
I Test Your Code And

var eventTarget = document.getElementById('__EVENTTARGET');

always empty for buttons - but it works for radcomboboxes with auto postback = true
========================================================================
i refered to this thread because after upload my web site to a host when u are in a page that contains radupload and radprogress area , when u click any button radprogress area appears ... whether radupload be empty or not...

what can i do to fix this problem ?
how can i tell to radupload have a private submit button?
is using the upper code good idea for solve this problem or not?

thanks for your future advise



0
Hassan Yasir
Top achievements
Rank 1
answered on 26 May 2010, 05:25 PM
Hello Majid,
One thing I would like to know is whether you're using an ASP:Button as an Upload Button?
If that is the case, you won't be able to reach the goal.

Try to use Linkbutton as your private upload button, and set it's ID as "ButtonUpload"
That's how it works!

If you can't achieve your goal, post your sample codes. I will review and can give you a example.

Thanks
0
Majid Darab
Top achievements
Rank 1
answered on 26 May 2010, 08:34 PM
hi Hassan Yasir
imagine that i have a content page that related to a master page...
in that content page i have a multiview and in one of those views i have a table for inputing data...(with radupload and 3 buttons for saving data in different conditions)
beside that radupload i have a LINKBUTTON (as u said) for saving my pix...and i do not want any of the other buttons for saving pix.
sometimes when u click on one of those 3 buttons for saving data RADPROGRESSAREA ppears for a second and this happens even no pic is selected in radupload...
so i refered to this thread to set a dedicate button for my RadUpload...
the upper code only  recognizes radcomboboxes(with AutoPostBack = True) and checkboxes (with AutoPostBack = True)
but about butons and link buttons it's eventTarget Is null ... i test it by alert
====================================================================================================
i set use submit behaviour for those buttons to false -> not help
i have many validators on that table and i can not disable CausesValidation of those buttons -> not help

hope this help to give an advice to me

best regards



0
Hassan Yasir
Top achievements
Rank 1
answered on 01 Jun 2010, 06:50 AM
Can u simply send me a sample in which you are causing that problem. So that I can fix the coding and send you back. I think it would take less time than discussing here.

Thanks
0
Alberto
Top achievements
Rank 1
answered on 08 Jul 2010, 06:05 PM
this method dos not work for RadAsyncUpload.
getFileInputs always returns empty!

any solution?
Tags
Upload (Obsolete)
Asked by
Hassan Yasir
Top achievements
Rank 1
Answers by
Majid Darab
Top achievements
Rank 1
Hassan Yasir
Top achievements
Rank 1
Alberto
Top achievements
Rank 1
Share this question
or