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

RadUpload1.UploadedFiles.Count = 0 with Window.Confirm

2 Answers 102 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Sudhanva
Top achievements
Rank 1
Sudhanva asked on 21 Jul 2009, 06:20 AM

 

 


Hi,

I have a scenario, where i need to show a confirm msg box, for user. i.e.

Please find the sample code for yout reference.

 

 <form id="form1" runat="server">  
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">  
</telerik:RadScriptManager> 
    <div> 
        <asp:Label ID="Label1" runat="server" ForeColor="Red" Visible="false"></asp:Label> 
      
        <telerik:RadUpload ID="RadUpload1" runat="server" ControlObjectsVisibility="None" 
            InputSize="34" Width="225px" ReadOnlyFileInputs="true" AllowedFileExtensions=".xls" 
            EnableFileInputSkinning="false">  
            <Localization Select="Browse" /> 
        </telerik:RadUpload> 
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" OnClientClick="window.confirm('This will replace the current file. Do you want to continue?');" /> 
    </div> 
    </form> 
c#
protected void Button1_Click(object sender, EventArgs e)  
    {  
        Label1.Visible = true;  
        if (RadUpload1.UploadedFiles.Count > 0)  
        {  
            //Code to save the file  
            Label1.Text = "File uploaded successfully";  
        }  
        else 
        {  
            Label1.Text = "Select a file to upload";  
        }  
    } 

With this the RadUpload1.UploadedFiles.Count is becoming zero. So i am unable to upload the file.

I know that Upload control has some drawbacks in order to maintain security.

Help me.

Thanks & Regards,
Sudhanva.

 

2 Answers, 1 is accepted

Sort by
0
Shankar
Top achievements
Rank 1
answered on 21 Sep 2009, 01:55 PM
Hi
Even i am facing same problem , file count is always  coming as zero.
ia using follwoing code in cs file

   foreach (UploadedFile file in RadUpload1.UploadedFiles)
        {
            file.SaveAs("C:\\VS2008 Projects\\TestUpload\\Files\\" + file.GetName(), true);
            
        }

RadUpload1.UploadedFiles  always comes as zero.





0
Qusay
Top achievements
Rank 1
answered on 13 Jun 2011, 02:12 PM
Maybe the RadUpload1 is Ajaxified withing a RadAjaxPanel control or something. If this is your case then you should unajaxify the code that counts the files in the RadUpload1 control. For more information about unajaxifying controls (to cause themm to postback the code to the server), please refer to this link: http://www.telerik.com/help/aspnet-ajax/ajax-exclude.html. Hope this helps.

 

Tags
Upload (Obsolete)
Asked by
Sudhanva
Top achievements
Rank 1
Answers by
Shankar
Top achievements
Rank 1
Qusay
Top achievements
Rank 1
Share this question
or