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

AsyncUpload and Rad grid funtionality is not working for IE8

1 Answer 70 Views
AsyncUpload
This is a migrated thread and some comments may be shown as answers.
Mary Presciba
Top achievements
Rank 1
Mary Presciba asked on 24 Oct 2013, 06:12 AM
Hi,

We have a code where we upload files using AsyncUpload control and as soon as the file is uploaded that will be added to the Radgrid control. Max of 5 uploads in allowed.
 This functionality is working fine in IE10,Chrome and firefox. But for IE8, after a file is uploaded it is added to the grid and if again a new file is uploaded, the previous file is updated with the new file in the grid instead of adding a new row. and when we click on send the file is not at all saved.A dummy click is called after the file upload to add the file to the grid. Can you please help us in this issue

thanks in Advance

Regards,
Mary

1 Answer, 1 is accepted

Sort by
0
Mary Presciba
Top achievements
Rank 1
answered on 24 Oct 2013, 08:46 AM
                <p>
                    Add attachment (optional)<br />
                    Up to five attachments are allowed. Maximum size per file is 10 MB.
                    Supported file types: <span id="supportedFileFormats"><%= string.Join(", ", Nokia.AWAP.APPortal.BusinessObjects.Validation.Queries.QueryValidatorSettings.SupportedFileFormats) %></span>.
                    <br />
                    <telerik:RadAsyncUpload runat="server" ID="UploadFiles"
                        Localization-Select="Browse" InputSize="35"
                        DisablePlugins="false"
                        MultipleFileSelection="Automatic"
                        MaxFileInputsCount="100"
                        MaxFileSize="10000000"
                        OnFileUploaded="UploadFiles_OnFileUploaded"
                        OnClientFilesUploaded="onClientAttachmentsUploaded"
                       />
                    </p>
                 
                   <div id="0_pastable" class="pastableHide">
                        Paste your image here (optional)
                        <div id="0_paste" class="paste" contenteditable="true"></div>
                    </div>
                     
                    <asp:PlaceHolder runat="server" ID="ShowFiles">
                        <div style="margin-bottom: 10px;">
                        <telerik:RadGrid ID="Files" runat="server" Visible="true" AutoGenerateColumns="false" Width="300"
                            OnItemDataBound="Files_OnItemDataBound"
                            OnNeedDataSource="Files_OnNeedDataSource"
                            OnItemCommand="Files_RowCommand" >
                            <MasterTableView DataKeyNames="FileName">
                                <Columns>
                                    <telerik:GridButtonColumn ButtonType="ImageButton" CommandName="DeleteRow"
                                        UniqueName="DeleteColumn" Text="Remove" HeaderStyle-Width="30" />
                                    <telerik:GridHyperLinkColumn
                                        DataTextField="FileName"
                                        DataNavigateUrlFields="UIId" DataNavigateUrlFormatString="../DownloadAttachment.ashx?id={0}&t=qnew" />
                                </Columns>
                            </MasterTableView>
                            <ClientSettings EnableAlternatingItems="false" />
                        </telerik:RadGrid>
                        </div>
                    </asp:PlaceHolder>                    
                                 
  
  
backend .cs code
        protected void UploadFiles_OnFileUploaded(object sender, FileUploadedEventArgs e)
        {
  
            var item = new PortalFileUpload(Guid.NewGuid().ToString(), e.File.FileName,
  
            GetContentType(e.File.FileName, e.File.ContentType),
  
            RadUploadHelper.GetFileBytes(e.File));
  
            var exists = Container.Attachments.Where(x => x.FileName.Equals(item.FileName, StringComparison.OrdinalIgnoreCase) &&
  
            x.Size == item.Size).SingleOrDefault();
  
            if (exists != null)
  
                Container.Attachments.Remove(exists);
  
            Container.Attachments.Add(item);
  
            Files.Rebind();
        }
  
        private string GetContentType(string fileName, string contentType)
        {
  
            if (contentType == null && fileName.EndsWith(".msg"))
  
                return "application/vnd.ms-outlook";
  
            return contentType;
  
        }
  
        protected void Dummy_Click(object sender, EventArgs e)
        {
  
            PopulateQuery();
  
            Files.Rebind();
  
        }
  
        protected void Files_OnItemDataBound(object sender, GridItemEventArgs e)
        {
  
            if (e.Item is GridDataItem)
            {
  
                GridDataItem item = (GridDataItem)e.Item;
  
                ImageButton imgButton = (ImageButton)item["DeleteColumn"].Controls[0];
  
                imgButton.ImageUrl = ResolveStaticUrl("images/icons/icon_delete.png");
  
            }
  
        }
  
        protected void Files_OnNeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
  
            if (!Container.Attachments.Any())
            {
  
                ShowFiles.Visible = false;
  
                return;
  
            }
  
            else
  
                ShowFiles.Visible = true;
  
            ((RadGrid)sender).DataSource = Container.Attachments;
  
        }
  
        protected void Files_RowCommand(object sender, GridCommandEventArgs e)
        {
  
            if (e.CommandName == "DeleteRow")
            {
  
                GridDataItem item = e.Item as GridDataItem;
  
                if (item != null)
                {
  
                    var fileToBeRemoved = item.GetDataKeyValue("FileName").ToString();
  
                    Container.Attachments.Remove(Container.Attachments.Where(file => file.FileName.Equals(fileToBeRemoved)).First());
  
                    if (Container.Attachments.Any())
  
                        ShowFiles.Visible = true;
  
                    else
  
                        ShowFiles.Visible = false;
  
                    Files.Rebind();
  
                }
  
            }
  
        }
Above is the code that we are using for uploading files
Tags
AsyncUpload
Asked by
Mary Presciba
Top achievements
Rank 1
Answers by
Mary Presciba
Top achievements
Rank 1
Share this question
or