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

RadUpload and RadAjaxManager problem

1 Answer 182 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
yasemin karagoz
Top achievements
Rank 1
yasemin karagoz asked on 30 Oct 2009, 12:56 PM
Hi;
I have a problem with RadAjaxManager and RadUpload.
I need to add an radiobutton check to a form that developed uses telerik functions such as RadTabStrip, RadMultiPage and RadUpload. I want to use RadAjaxManager.UpDatedControls instead of autopostback of radiobuttons to make a textbox invisible before clicking "upload" button and upload a excel or csv file.
But by the time AjaxUpdatedControls works, RadUpload stops working and I can not upload my file to the system. When I disabled the AjaxUpdatedControls and use radiobutton autopostback I can load the file.
Here is a part of my code. Please help and show my mistakes.

<%@ Register Assembly="System.Web.Extensions" Namespace="System.Web.UI" TagPrefix="asp" %> 
<%@ Register Assembly="odc.Web" Namespace="odc.Web.Controls" TagPrefix="odc" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
 
 
<asp:Content ID="Content1" ContentPlaceHolderID="phMain" runat="Server">  
      
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="excelRadioButton">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="pnlDosyaBilgileri" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="csvRadioButton">  
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="pnlDosyaBilgileri" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
<div runat="server" id="divExcelLoad">  
                                <asp:Panel ID="pnlDosyaBilgileri" runat="server" SkinID="webPanel" GroupingText="Dosya Bilgileri">  
                                    <table border="0" cellpadding="3" cellspacing="0" width="100%">  
                                        <tr> 
                                            <td class="strB">  
                                                <asp:Literal ID="Literal1" runat="server" Text="Please choose the file type:"/>  
                                            </td> 
                                            <td>                                              
                                                <asp:RadioButton ID="excelRadioButton" runat="server" GroupName="excelCsvRadio"   
                                                    SkinID="webRadio" Text="Excel Dosyası" Checked="true" AutoPostBack="True" oncheckedchanged="excelRadioButton_CheckedChanged"/>  
                                                <asp:RadioButton ID="csvRadioButton" runat="server" GroupName="excelCsvRadio"   
                                                    SkinID="webRadio" Text="Csv Dosyası" AutoPostBack="True" oncheckedchanged="csvRadioButton_CheckedChanged"   
                                                     /> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td class="strB">  
                                                <asp:Literal ID="lblSelectExcel" runat="server" Text="Dosyayı Seçiniz:"/>  
                                            </td> 
                                            <td> 
                                                <telerik:RadUpload ID="RadUpload1" Skin="Vista" runat="server" OverwriteExistingFiles="true" InitialFileInputsCount="1" MaxFileInputsCount="1" TargetFolder="~/Temp" ControlObjectsVisibility="None" /> 
                                            </td> 
                                            <td> 
                                            </td> 
                                        </tr> 
                                        <tr> 
                                            <td colspan="3" align="center">  
                                                <telerik:RadProgressManager ID="Radprogressmanager1" runat="server" /> 
                                                <telerik:RadProgressArea ID="progressArea1" runat="server" ProgressIndicators="FilesCountBar,FilesCountPercent,TransferSpeed" DisplayCancelButton="true" /> 
                                            </td> 
                                        </tr> 
 
                                        <tr> 
                                            <td class="strB">  
                                                <asp:Literal ID="lblWorkSheetName" runat="server" Text="Worksheet Name:" /> 
                                              
                                            </td> 
                                            <td> 
                                                <asp:TextBox ID="txtSheetName" SkinID="webTextbox" runat="server" Text="Sheet1" ></asp:TextBox>&nbsp;<asp:RequiredFieldValidator ID="rfvSheetName" runat="server" ErrorMessage="Please enter the worksheet name." ControlToValidate="txtSheetName"><img alt="" src="../Images/dikkat.gif"/></asp:RequiredFieldValidator> 
                                            </td> 
                                            <td valign="bottom" align="left">  
                                                <asp:Button ID="btnPreviousLoad" OnClick="Geri" runat="server" Text="Back" SkinID="webButtonM" /> 
                                                <asp:Button ID="btnLoadExcel" runat="server" SkinID="webButtonM" Text="Upload" OnClick="btnLoadExcel_Click" /> 
                                            </td> 
                                        </tr> 
                                    </table> 
                                </asp:Panel> 
                            </div> 

1 Answer, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 02 Nov 2009, 09:29 AM
Hello yasemin karagoz,

RadUpload cannot upload files using AJAX calls. This is a limitation of the XmlHttpRequest component, used in all AJAX frameworks for asynchronous calls to the application. In order to upload a file your application must perform a full page postback.

The solution is to attach the following function to the OnRequestStart client side event of your RadAjaxManager:

<RadScriptBlock ID="RadScriptBlock1" runat="server">
 <script type="text/javascript">
   // on upload button click temporarily disables ajax to perform
   // upload actions
   function conditionalPostback(sender, args)
   {
      if (args.get_eventTarget() == "<%= ButtonSubmit.UniqueID %>")
      {
          args.set_enableAjax(false);
      }
 }
 </script>
</RadScriptBlock>
 

More information on the topic can be found here.

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.
Tags
Upload (Obsolete)
Asked by
yasemin karagoz
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Share this question
or