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

Duplicate AsyncUpload input field on published version

3 Answers 107 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Marius
Top achievements
Rank 1
Marius asked on 30 Sep 2014, 07:53 AM
I have a RadGrid that has a RadAsyncUpload control int  the edit item template :

   <telerik:GridTemplateColumn DataField="Data" HeaderText="Image" UniqueName="Upload">
                                    <ItemTemplate>
                                        <telerik:RadBinaryImage runat="server" ID="RadBinaryImage1" DataValue='<%#Eval("Data") %>'
                                            AutoAdjustImageControlSize="false" Height="40px" ImageUrl="~/images/icons/PDF.png"></telerik:RadBinaryImage>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <telerik:RadAsyncUpload runat="server" ID="AsyncUpload1" OnClientFileUploaded="OnClientFileUploaded"
                                            AllowedFileExtensions="jpg,jpeg,png,gif,pdf,tiff,tif" MaxFileSize="1048576" OnFileUploaded="AsyncUpload1_FileUploaded"  MaxFileInputsCount="1" ChunkSize="0">
                                        </telerik:RadAsyncUpload>
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>

When testing through Visual Studio it performs like a charm.  However as soon as I publish it for UAT the input field of the upload control is duplicated. See attached screenshots. I have tried all edit modes... Any ideas out there?

3 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 03 Oct 2014, 05:49 AM
Hello Marius,

I am sorry to say but the information provided is not sufficient for us to determine what is causing the illustrated behavior. Could you please send us the page markup and code-behind for review? Additionally please elaborate more on the exact version of the controls used in the application.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Marius
Top achievements
Rank 1
answered on 07 Oct 2014, 07:17 AM
Here you go:

Current control version for Telerik :  v.2013.2.717.45

Page markup :
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ucLogDocument.ascx.cs" Inherits="Cubed.CoreSystem.UserControls.ucLogDocument" %>
<%@ Register Assembly="Cubed" Namespace="Cubed.WebClasses" TagPrefix="cc1" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%@ Register Src="~/CoreSystem/UserControls/ucCreateRFS.ascx" TagPrefix="uc1" TagName="ucCreateRFS" %>
<%@ Register Src="~/FinancialSystem/UserControls/ucUserMessageBox.ascx" TagName="UserMessageBox" TagPrefix="uc2" %>


<link href="../../Styles/Site.css" rel="stylesheet" type="text/css" />
<style type="text/css">
    .auto-style1 {
        width: 100%;
    }

    .auto-style3 {
        height: 20px;
    }

    .auto-style7 {
        font-family: Arial, Helvetica, sans-serif;
        font-size: 11px;
        font-weight: bold;
        color: #003366;
        background-color: #BFD3F2;
        vertical-align: middle;
        position: inherit;
        text-align: right;
        height: 20px;
    }
</style>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">

    <ContentTemplate>

        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
            <script type="text/javascript">
                var uploadedFilesCount = 0;
                var isEditMode;
                function validateRadUpload(source, e) {
                    // When the RadGrid is in Edit mode the user is not obliged to upload file.
                    if (isEditMode == null || isEditMode == undefined) {
                        e.IsValid = false;

                        if (uploadedFilesCount > 0) {
                            e.IsValid = true;
                        }
                    }
                    isEditMode = null;
                }

                function OnClientFileUploaded(sender, eventArgs) {
                    uploadedFilesCount++;
                }

            </script>
        </telerik:RadCodeBlock>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="rgFiles">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rgFiles"></telerik:AjaxUpdatedControl>
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Always">
            <ContentTemplate>
                <div>
                    <table class="auto-style1">
                        <tr>
                            <td class="auto-style3"></td>
                        </tr>
                        <tr>
                            <td class="tableheader1">Documents to be attached to new RFS:</td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                        </tr>
                    </table>

                    <telerik:RadGrid runat="server" ID="rgFiles" AllowPaging="True" AllowSorting="True"
                        AutoGenerateColumns="False" ShowStatusBar="True" GridLines="None"
                        OnItemCreated="rgFiles_ItemCreated" PageSize="3" OnInsertCommand="rgFiles_InsertCommand"
                        OnNeedDataSource="rgFiles_NeedDataSource" OnDeleteCommand="rgFiles_DeleteCommand"
                        OnUpdateCommand="rgFiles_UpdateCommand" OnItemCommand="rgFiles_ItemCommand" Skin="Outlook" CellSpacing="0" EnableTheming="False" OnPreRender="rgFiles_PreRender">
                        <PagerStyle Mode="NumericPages" AlwaysVisible="true"></PagerStyle>
                        <ExportSettings>
                            <Pdf PageWidth="">
                            </Pdf>
                        </ExportSettings>
                        <MasterTableView Width="100%" CommandItemDisplay="Top" DataKeyNames="URL" NoMasterRecordsText="No documents selected" EditMode="InPlace">
                            <CommandItemSettings AddNewRecordText="Select a new document" />
                            <Columns>
                                <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderText="Action">
                                    <HeaderStyle Width="36px"></HeaderStyle>
                                </telerik:GridEditCommandColumn>
                                <telerik:GridTemplateColumn DataField="Data" HeaderText="Image" UniqueName="Upload">
                                    <ItemTemplate>
                                        <telerik:RadBinaryImage runat="server" ID="RadBinaryImage1" DataValue='<%#Eval("Data") %>'
                                            AutoAdjustImageControlSize="false" Height="40px" ImageUrl="~/images/icons/PDF.png"></telerik:RadBinaryImage>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <telerik:RadAsyncUpload runat="server" ID="AsyncUpload1" OnClientFileUploaded="OnClientFileUploaded"
                                            AllowedFileExtensions="jpg,jpeg,png,gif,pdf,tiff,tif" MaxFileSize="1048576" OnFileUploaded="AsyncUpload1_FileUploaded"  MaxFileInputsCount="1" ChunkSize="0">
                                        </telerik:RadAsyncUpload>
                                    </EditItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn HeaderText="Description" UniqueName="Description" DataField="Description">
                                    <ItemTemplate>
                                        <asp:Label ID="lblDescription" runat="server" Text='<%# TrimDescription(Eval("Description") as string) %>'></asp:Label>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                        <telerik:RadTextBox ID="txbDescription" Width="100%" runat="server" TextMode="MultiLine"
                                            Text='<%# Eval("Description") %>' Height="40px">
                                        </telerik:RadTextBox>
                                    </EditItemTemplate> 
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn FilterControlAltText="Filter Name column" UniqueName="Name" DataField="Name" HeaderText="File" ReadOnly="True">
                                    <EditItemTemplate> 
                                    </EditItemTemplate>
                                    <ItemTemplate>
                                        <asp:Label ID="Label2" runat="server" Text='<%# TrimDescription(Eval("Name") as string) %>'></asp:Label>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn FilterControlAltText="Filter Extension column" UniqueName="Extension" DataField="Extension" HeaderText="Type" ReadOnly="True">
                                    <EditItemTemplate>
                                        </EditItemTemplate> 
                                    <ItemTemplate>
                                        <asp:Label ID="Label1" runat="server" Text='<%# TrimDescription(Eval("Extension") as string) %>'></asp:Label>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridTemplateColumn FilterControlAltText="Filter column column" UniqueName="URLLink" EditFormHeaderTextFormat="{0}">
                                    <EditItemTemplate> 
                                        </EditItemTemplate> 
                                    <ItemTemplate>
                                        <asp:HyperLink runat="server" ID="linktoopen" NavigateUrl="~/temp/Muststay.txt"  ImageUrl="~/images/icons/view.png" Target="_blank"></asp:HyperLink>
                                    </ItemTemplate>
                                </telerik:GridTemplateColumn>
                                <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="ImageButton">
                                    <HeaderStyle Width="36px"></HeaderStyle>
                                </telerik:GridButtonColumn>
                            </Columns>
                            <EditFormSettings>
                                <EditColumn ButtonType="ImageButton">
                                </EditColumn>
                            </EditFormSettings>
                            <PagerStyle AlwaysVisible="True"></PagerStyle>
                        </MasterTableView>
                    </telerik:RadGrid>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>



        <asp:UpdatePanel ID="UpdatePanel2" runat="server" >
            <ContentTemplate>
                <div id="rfsdiv" visible ="false">
                    <table class="auto-style1">
                        <tr>
                            <td colspan="4">&nbsp;</td>
                        </tr>
                        <tr>
                            <td class="tableheader1" colspan="4">Documents selected will be attached to a new RFS with the following attributes :</td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                        </tr>
                    </table>
                    <table style="width: 100%">
                        <tr>
                            <td>
                                <div>

                                    <table style="width: 100%">
                                        <tr>
                                            <td style="font-family: Arial, Helvetica, sans-serif; width: 90%;">
                                                <telerik:RadTextBox ID="tb_RFSNote" runat="server" EmptyMessage="Please enter a note ..." Height="80px" Skin="Outlook" TextMode="MultiLine" Width="100%">
                                                </telerik:RadTextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="font-family: Arial, Helvetica, sans-serif; font-size: 14px">
                                                <asp:RequiredFieldValidator ID="rfvnote" runat="server" ControlToValidate="tb_RFSNote" ErrorMessage="RFS Note is required!" ForeColor="#CC3300" ValidationGroup="rfsrequired">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                    </table>

                                    <table style="width: 100%; height: 41px;">
                                        <tr>
                                            <td class="auto-style7">Document Section:</td>
                                            <td class="auto-style3">
                                                <telerik:RadComboBox ID="rcbDocSect" runat="server" AutoPostBack="True" DataSourceID="ODSDocSect" DataTextField="Descr" DataValueField="DocSect" EmptyMessage="Select Document Section ..." Skin="Outlook" Width="80%" OnSelectedIndexChanged="rcbDocSect_SelectedIndexChanged">
                                                </telerik:RadComboBox>
                                                <asp:RequiredFieldValidator ID="rfvdocsect" runat="server" ControlToValidate="rcbDocSect" ErrorMessage="Document Section is required!" ForeColor="#CC3300" ValidationGroup="rfsrequired">*</asp:RequiredFieldValidator>
                                            </td>
                                            <td class="auto-style7">Document Sub Section:</td>
                                            <td class="auto-style3">
                                                <telerik:RadComboBox ID="rcbDocSubSect" runat="server" DataSourceID="ODSDocSubSect" DataTextField="Descr" DataValueField="DocSubSect" EmptyMessage="Select Document Sub Section ..." Skin="Outlook" Width="80%" OnSelectedIndexChanged="rcbDocSubSect_SelectedIndexChanged" AutoPostBack="True">
                                                </telerik:RadComboBox>
                                                <asp:RequiredFieldValidator ID="rfvdocsubsect" runat="server" ControlToValidate="rcbDocSubSect" ErrorMessage="Document Sub Section is required!" ForeColor="#CC3300" ValidationGroup="rfsrequired">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="auto-style7">Caller Category:</td>
                                            <td class="auto-style3">
                                                <telerik:RadComboBox ID="ddl_CallerCat" runat="server" AutoPostBack="True" DataSourceID="ODSCallerCat" DataTextField="CallerCatDescr" DataValueField="CallerCatCode" EmptyMessage="Select Caller Category ..." Skin="Outlook" Width="160px" OnSelectedIndexChanged="ddl_CallerCat_SelectedIndexChanged">
                                                </telerik:RadComboBox>
                                                &nbsp;<asp:RequiredFieldValidator ID="rfvcallercat" runat="server" ControlToValidate="ddl_CallerCat" ErrorMessage="Caller Category is required!" ForeColor="#CC3300" ValidationGroup="rfsrequired">*</asp:RequiredFieldValidator>
                                            </td>
                                            <td class="auto-style7">Work Basket:</td>
                                            <td class="auto-style3">
                                                <telerik:RadComboBox ID="ddl_WrkBasket" runat="server" DataSourceID="ODSWrkBaskets" DataTextField="Descr" DataValueField="WrkBasketCode" EmptyMessage="Select Work Basket ..." Skin="Outlook" OnSelectedIndexChanged="ddl_WrkBasket_SelectedIndexChanged" AutoPostBack="True">
                                                </telerik:RadComboBox>
                                                &nbsp;<asp:RequiredFieldValidator ID="rfvwrkbasket" runat="server" ControlToValidate="ddl_WrkBasket" ErrorMessage="Work Basket is required!" ForeColor="#CC3300" ValidationGroup="rfsrequired">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tablelabel">Call Category:</td>
                                            <td class="auto-style2">
                                                <telerik:RadComboBox ID="ddl_CallCat" runat="server" DataSourceID="ODSCallCat" DataTextField="CallCatDescr" DataValueField="CallCatCode" Skin="Outlook" AutoPostBack="True" EmptyMessage="Select Call Category..." OnSelectedIndexChanged="ddl_CallCat_SelectedIndexChanged">
                                                </telerik:RadComboBox>
                                                &nbsp;<asp:RequiredFieldValidator ID="rfvcallcat" runat="server" ControlToValidate="ddl_CallCat" ErrorMessage="Call Category is required!" ForeColor="#CC3300" ValidationGroup="rfsrequired">*</asp:RequiredFieldValidator>
                                            </td>
                                            <td class="tablelabel">RFS Priority:</td>
                                            <td class="auto-style2">
                                                <telerik:RadComboBox ID="ddl_RFSPriority" runat="server" DataSourceID="ODSRFSPriorities" DataTextField="Descr" DataValueField="RFSPriority" EmptyMessage="Select RFS Priority ..." Skin="Outlook" AutoPostBack="True" OnSelectedIndexChanged="ddl_RFSPriority_SelectedIndexChanged">
                                                </telerik:RadComboBox>
                                                &nbsp;<asp:RequiredFieldValidator ID="rfvpriority" runat="server" ControlToValidate="ddl_RFSPriority" ErrorMessage="RFS Priority is required!" ForeColor="#CC3300" ValidationGroup="rfsrequired">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tablelabel">Call Sub Category:</td>
                                            <td class="auto-style2">
                                                <telerik:RadComboBox ID="ddl_CallSubCat" runat="server" DataSourceID="ODSCallSubCat" DataTextField="CallSubCatDescr" DataValueField="CallSubCatCode" Skin="Outlook" AutoPostBack="True" EmptyMessage="Select Call Sub Category..." OnSelectedIndexChanged="ddl_CallSubCat_SelectedIndexChanged">
                                                </telerik:RadComboBox>
                                                &nbsp;<asp:RequiredFieldValidator ID="rfvcallsubcat" runat="server" ControlToValidate="ddl_CallSubCat" ErrorMessage="Call Sub Category is required!" ForeColor="#CC3300" ValidationGroup="rfsrequired">*</asp:RequiredFieldValidator>
                                            </td>
                                            <td class="tablelabel">RFS Status:</td>
                                            <td class="auto-style2">
                                                <telerik:RadComboBox ID="ddl_RFSStatus" runat="server" DataSourceID="ODSRFSStatus" DataTextField="Descr" DataValueField="RFSStatusCode" EmptyMessage="Select RFS Status ..." Skin="Outlook" OnSelectedIndexChanged="ddl_RFSStatus_SelectedIndexChanged" AutoPostBack="True">
                                                </telerik:RadComboBox>
                                                &nbsp;<asp:RequiredFieldValidator ID="rfvstatus" runat="server" ControlToValidate="ddl_RFSStatus" ErrorMessage="RFS Status is required!" ForeColor="#CC3300" ValidationGroup="rfsrequired">*</asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="tablelabel">Call Channel:</td>
                                            <td class="auto-style2">
                                                <telerik:RadComboBox ID="ddl_CallChannel" runat="server" DataSourceID="ODSCallChannel" DataTextField="Descr" DataValueField="CallChannelCode" Skin="Outlook" EmptyMessage="Select Call Channel..." OnSelectedIndexChanged="ddl_CallChannel_SelectedIndexChanged" AutoPostBack="True">
                                                </telerik:RadComboBox>
                                                &nbsp;<asp:RequiredFieldValidator ID="rfvcallchannel" runat="server" ControlToValidate="ddl_CallChannel" ErrorMessage="Caller Channel is required!" ForeColor="#CC3300" ValidationGroup="rfsrequired">*</asp:RequiredFieldValidator>
                                            </td>
                                            <td class="auto-style2">&nbsp;</td>
                                            <td class="auto-style2">&nbsp;</td>
                                        </tr>
                                        <tr>
                                            <td class="auto-style2" colspan="4">
                                                <asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="rfsrequired" ForeColor="#CC3300" HeaderText="The following field(s) are required to complete this process :" />
                                            </td>

                                        </tr>
                                        <tr>
                                            <td style="font-family: Arial, Helvetica, sans-serif; font-size: 14px" colspan="4">



                                                <telerik:RadButton ID="btn_ActRFS" runat="server" Text="Create RFS" OnClick="btn_ActRFS_Click" ValidationGroup="rfsrequired"></telerik:RadButton>

                                                <uc2:UserMessageBox ID="umb_processmessage" runat="server" />

                                            </td>

                                        </tr>
                                    </table>
                                </div>
                            </td>
                        </tr>
                    </table>

                    <asp:LinkButton ID="LinkButton2" runat="server" ForeColor="White"></asp:LinkButton>
                    <asp:ModalPopupExtender ID="MPECall" runat="server" PopupControlID="pnl_callend"
                        TargetControlID="LinkButton2">
                    </asp:ModalPopupExtender>

                    <asp:LinkButton ID="LinkButton1" runat="server" ForeColor="White"></asp:LinkButton>

                    <asp:ModalPopupExtender ID="MPEError1" runat="server" PopupControlID="pnl_error1"
                        TargetControlID="LinkButton1" OkControlID="btnOK">
                    </asp:ModalPopupExtender>


                    <asp:LinkButton ID="LinkButton3" runat="server" ForeColor="White"></asp:LinkButton>

                    <asp:ModalPopupExtender ID="MPESuccess" runat="server" PopupControlID="pnl_success1"
                        TargetControlID="LinkButton3">
                    </asp:ModalPopupExtender>
                </div>

            </ContentTemplate>
        </asp:UpdatePanel>
    </ContentTemplate>
</asp:UpdatePanel>


<asp:ObjectDataSource ID="ODSDocSect" runat="server" SelectMethod="ListDocSect" TypeName="Cubed.DropDownListsService.DropDownListsClient"></asp:ObjectDataSource>

<asp:ObjectDataSource ID="ODSDocSubSect" runat="server" SelectMethod="ListDocSubSect" TypeName="Cubed.DropDownListsService.DropDownListsClient">
    <SelectParameters>
        <asp:ControlParameter ControlID="rcbDocSect" Name="sdocsect" PropertyName="SelectedValue" Type="String" />
    </SelectParameters>
</asp:ObjectDataSource>


<asp:Panel ID="pnl_callend" runat="server" BackColor="white" BorderStyle="Outset" Width="400" Style="display: none">
    <div style="padding: 10px; background-color: ActiveCaption; text-align: center;">
        <span style="font-family: Arial;">Please confirm your action</span>
        <br />
    </div>
    <p style="text-align: center;">
        Please click the button of your choice.
    </p>
    <p style="text-align: center;">

        <asp:Button ID="endBtn" runat="server" Text="End Call Only" OnClick="endBtn_Click" />
        <asp:Button ID="endnewbtn" runat="server" Text="End Call and Initialise New" OnClick="endnewbtn_Click" />
        <asp:Button ID="cancelBtn" runat="server" Text="Return to Current Call" OnClick="cancelBtn_Click" />
    </p>
</asp:Panel>


<asp:ObjectDataSource ID="ODSWrkBaskets" runat="server" SelectMethod="ListRFSWorkBaskets" TypeName="Cubed.DropDownListsService.DropDownListsClient">
    <SelectParameters>
        <asp:SessionParameter Name="username" SessionField="UserName" Type="String" />
    </SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ODSRFSPriorities" runat="server" SelectMethod="ListRFSPriorities" TypeName="Cubed.DropDownListsService.DropDownListsClient"></asp:ObjectDataSource>
<asp:ObjectDataSource ID="ODSRFSStatus" runat="server" SelectMethod="ListRFSStatus" TypeName="Cubed.DropDownListsService.DropDownListsClient"></asp:ObjectDataSource>

<asp:ObjectDataSource ID="ODSCallerCat" runat="server" SelectMethod="ListCallerCat" TypeName="Cubed.DropDownListsService.DropDownListsClient"></asp:ObjectDataSource>
<asp:ObjectDataSource ID="ODSCallCat" runat="server" SelectMethod="ListCallCat" TypeName="Cubed.DropDownListsService.DropDownListsClient">
    <SelectParameters>
        <asp:ControlParameter ControlID="ddl_CallerCat" Name="CallerCatCode" PropertyName="SelectedValue" Type="String" />
    </SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ODSCallSubCat" runat="server" SelectMethod="ListCallSubCat" TypeName="Cubed.DropDownListsService.DropDownListsClient">
    <SelectParameters>
        <asp:ControlParameter ControlID="ddl_CallCat" Name="CallCatCode" PropertyName="SelectedValue" Type="String" />
        <asp:ControlParameter ControlID="ddl_CallerCat" Name="CallerCatCode" PropertyName="SelectedValue" Type="String" />
    </SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ODSCallChannel" runat="server" SelectMethod="ListCallChannels" TypeName="Cubed.DropDownListsService.DropDownListsClient"></asp:ObjectDataSource>


<asp:Panel ID="pnl_error1" runat="server" BackColor="white" BorderStyle="Outset" Width="400" Style="display: none">

    <div style="padding: 10px; background-color: ActiveCaption; text-align: center;">
        <span style="font-family: Arial;">ERROR on create of RFS</span>
        <br />
    </div>
    <p style="text-align: center;">
        The createion of and RFS has returned unsuccesfull. Please try again. Should this problem persist, please contact your system administrator.
    </p>
    <p style="text-align: center;">
        <telerik:RadTextBox ID="tb_ErrMessage" runat="server" Width="300" Height="80" EmptyMessage="No return message" EnabledStyle-HorizontalAlign="Justify"></telerik:RadTextBox>
    </p>

    <p style="text-align: center;">
        &nbsp;<telerik:RadButton runat="server" Text="OK" ID="btnOK"></telerik:RadButton>
        <p>
        </p>
    </p>
</asp:Panel>

<asp:Panel ID="pnl_success1" runat="server" BackColor="white" BorderStyle="Outset" Width="400" Style="display: none">

    <div style="padding: 10px; background-color: ActiveCaption; text-align: center;">
        <span style="font-family: Arial;">RFS Created
        </span>
        <br />
    </div>
    <p style="text-align: center;">
        An RFS was successfully created.
    </p>
    <p style="text-align: center;">
        <telerik:RadTextBox ID="tbOKMessage" runat="server" Width="300" Height="80" EmptyMessage="No return message" EnabledStyle-HorizontalAlign="Justify" TextMode="MultiLine"></telerik:RadTextBox>
    </p>



    <p style="text-align: center;">
        &nbsp;<telerik:RadButton runat="server" Text="OK" ID="btnYes" OnClick="btnYes_Click"></telerik:RadButton> 
        <p>
        </p>
    </p>
</asp:Panel>


Code Behind:
using Cubed.common;
using Cubed.WebClasses;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;


namespace Cubed.CoreSystem.UserControls
{
    public partial class ucLogDocument : AbstractBaseControl
    {
        const int MaxTotalBytes = 1048576; // 1 MB
        Int64 totalBytes;

        public bool? IsRadAsyncValid
        {
            get
            {
                if (Session["IsRadAsyncValid"] == null)
                {
                    Session["IsRadAsyncValid"] = true;
                }

                return Convert.ToBoolean(Session["IsRadAsyncValid"].ToString());
            }
            set
            {
                Session["IsRadAsyncValid"] = value;
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                string CallSubCatCode;
                string CallCatCode;
                string CallerCatCode;
                CallSubCatCode = sessionInfo.SessionObject().ControlInfo.CallSubCat;
                CallCatCode = sessionInfo.SessionObject().ControlInfo.CallCat;
                CallerCatCode = sessionInfo.SessionObject().ControlInfo.CallerCat;
            }
        } 

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            IsRadAsyncValid = null;
        }

        protected void rgFiles_ItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                RadAsyncUpload upload = ((GridEditableItem)e.Item)["Upload"].FindControl("AsyncUpload1") as RadAsyncUpload;
                TableCell cell = (TableCell)upload.Parent;

                CustomValidator validator = new CustomValidator();
                validator.ErrorMessage = "Please select file to be uploaded";
                validator.ClientValidationFunction = "validateRadUpload";
                validator.Display = ValidatorDisplay.Dynamic;
                cell.Controls.Add(validator);
            }
            else if (e.Item is GridDataItem)
            {
                GridDataItem item = (GridDataItem)e.Item;
                string val1 = item.GetDataKeyValue("URL").ToString();
                HyperLink hLink = (HyperLink)item.FindControl("linktoopen");
                hLink.NavigateUrl = val1;
            }
        }

        protected string TrimDescription(string description)
        {
            if (!string.IsNullOrEmpty(description) && description.Length > 200)
            {
                return string.Concat(description.Substring(0, 200), "...");
            }
            return description;
        }

        protected void rgFiles_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            rgFiles.DataSource = GetDataTable;
        }

        protected void rgFiles_InsertCommand(object source, GridCommandEventArgs e)
        {
            if (!IsRadAsyncValid.Value)
            {
                e.Canceled = true;
                RadAjaxManager1.Alert("The length of the uploaded file must be less than 1 MB");
                return;
            }

            GridDataInsertItem insertItem = e.Item as GridDataInsertItem;
            string description = (insertItem["Description"].FindControl("txbDescription") as RadTextBox).Text;
            RadAsyncUpload radAsyncUpload = insertItem["Upload"].FindControl("AsyncUpload1") as RadAsyncUpload;

            UploadedFile file = radAsyncUpload.UploadedFiles[0];


            string filename = file.FileName;

            string extension = file.GetExtension().ToUpper();

            string test = file.GetExtension().ToUpper(); ;

            test = radAsyncUpload.UploadedFiles[0].GetName();

            string URL = Guid.NewGuid().ToString("N") + extension;

            string  Location = System.Configuration.ConfigurationManager.AppSettings["RelativePath"];
             
            string SaveFile = Server.MapPath(Location + "/temp/" + URL);

            URL = "~\\temp\\" + URL;

            radAsyncUpload.UploadedFiles[0].SaveAs(SaveFile);

            byte[] fileData = new byte[0];

            if (extension == ".PDF")
            {
                string iconfile = Server.MapPath("/images/icons/") + "pdflargeicon.jpg";
                System.Drawing.Image img = System.Drawing.Image.FromFile(iconfile);

                using (MemoryStream ms = new MemoryStream())
                {
                    img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                    fileData = ms.ToArray();
                }
            }
            else
            {

                System.Drawing.Image img = System.Drawing.Image.FromFile(SaveFile);

                using (MemoryStream ms = new MemoryStream())
                {
                    img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                    fileData = ms.ToArray();
                }

            }


            Object obj = Session["_gdsFiles"];

            DataTable myDataTable = new DataTable();

            myDataTable = (DataTable)obj;

            myDataTable.Rows.Add(fileData, description, filename, extension, URL);

            Session["_gdsFiles"] = myDataTable;


        }

        protected void rgFiles_UpdateCommand(object source, GridCommandEventArgs e)
        {
            if (!IsRadAsyncValid.Value)
            {
                e.Canceled = true;
                RadAjaxManager1.Alert("The length of the uploaded file must be less than 1 MB");
                return;
            }
            GridEditableItem editedItem = e.Item as GridEditableItem;
            string description = (editedItem["Description"].FindControl("txbDescription") as RadTextBox).Text;
            RadAsyncUpload radAsyncUpload = editedItem["Upload"].FindControl("AsyncUpload1") as RadAsyncUpload;

            Object obj = Session["_gdsFiles"];

            DataTable myDataTable = new DataTable();

            myDataTable = (DataTable)obj;

            myDataTable.Rows[editedItem.ItemIndex][0] = null;
            myDataTable.Rows[editedItem.ItemIndex][1] = description;
            myDataTable.Rows[editedItem.ItemIndex][2] = null;
            myDataTable.Rows[editedItem.ItemIndex][3] = null;
            myDataTable.Rows[editedItem.ItemIndex][4] = null;

            if (radAsyncUpload.UploadedFiles.Count > 0)
            {
                UploadedFile file = radAsyncUpload.UploadedFiles[0];

                string filename = file.FileName;

                string extension = file.GetExtension().ToUpper();

                string test = file.GetExtension().ToUpper();

                string URL = Guid.NewGuid().ToString("N") + extension;
                 
                string Location = System.Configuration.ConfigurationManager.AppSettings["RelativePath"];

                string SaveFile = Server.MapPath(Location + "/temp/" + URL);

                URL = "~\\temp\\" + URL;

                radAsyncUpload.UploadedFiles[0].SaveAs(SaveFile, true);

                byte[] fileData = new byte[0];

                if (extension == ".PDF")
                {
                    string iconfile = Server.MapPath("/images/icons/") + "pdflargeicon.jpg";
                    System.Drawing.Image img = System.Drawing.Image.FromFile(iconfile);

                    using (MemoryStream ms = new MemoryStream())
                    {
                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                        fileData = ms.ToArray();
                    }
                }
                else
                {

                    System.Drawing.Image img = System.Drawing.Image.FromFile(SaveFile);

                    using (MemoryStream ms = new MemoryStream())
                    {
                        img.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
                        fileData = ms.ToArray();
                    }

                }

                myDataTable.Rows[editedItem.ItemIndex][1] = fileData;
                myDataTable.Rows[editedItem.ItemIndex][2] = filename;
                myDataTable.Rows[editedItem.ItemIndex][3] = extension;
                myDataTable.Rows[editedItem.ItemIndex][4] = URL;
            }

            Session["_gdsFiles"] = myDataTable;


        }

        protected void rgFiles_DeleteCommand(object source, GridCommandEventArgs e)
        {
            // string ID = (e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ID"].ToString();

            //using (SqlConnection conn = new SqlConnection(ConnectionString))
            //{
            //    conn.Open();
            //    SqlCommand cmd = new SqlCommand("DELETE FROM Images WHERE ID = @ID", conn);

            //    cmd.Parameters.Add("@ID", SqlDbType.Int);

            //    cmd.Parameters["@ID"].Value = ID;
            //    cmd.ExecuteScalar();
            //}
        }

        protected void rgFiles_ItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.CommandName == RadGrid.EditCommandName)
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "SetEditMode", "isEditMode = true;", true);
            }
        }

        protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
        {
            if ((totalBytes < MaxTotalBytes) && (e.File.ContentLength < MaxTotalBytes))
            {
                e.IsValid = true;
                totalBytes += e.File.ContentLength;
                IsRadAsyncValid = true;
            }
            else
            {
                e.IsValid = false;
                IsRadAsyncValid = false;
            }
        }

        private DataTable GetDataTable
        {
            get
            {
                Object obj = Session["_gdsFiles"];
                if (obj != null)
                {
                    return (DataTable)obj;
                }
                else
                {
                    DataTable myDataTable = new DataTable();

                    myDataTable.Columns.Add("Data", typeof(byte[]));
                    myDataTable.Columns.Add("Description", typeof(string));
                    myDataTable.Columns.Add("Name", typeof(string));
                    myDataTable.Columns.Add("Extension", typeof(string));
                    myDataTable.Columns.Add("URL", typeof(string));


                    Session["_gdsFiles"] = myDataTable;

                    return myDataTable;
                }
            }
        }

        protected void btn_ActRFS_Click(object sender, EventArgs e)
        {

            if (!validateAction())
            { return; }

            decimal? RFSLogNum;
            decimal? CaseNum;
            decimal? ClmNum;
            int? MemNum;
            decimal? PracNum;
            DateTime? RFSDateLog;
            DateTime? ReqBy;
            string RFSStatusCode;
            DateTime? RFSStatusAsAt;
            string AssignedTo;
            decimal? RFSPriority;
            string CallSubCatCode;
            string CallCatCode;
            string CallerCatCode;
            string CallChannelCode;
            string WrkBasketCode;
            string Descr;
            decimal? CallNum;
            DateTime? RecvDate;
            string UserName;

            switch (sessionInfo.SessionObject().ControlInfo.CurrentProcessCode)
            {
                case ("CLSCN"):
                    //Prepare everything for webservice
                    RFSLogNum = null;
                    CaseNum = null;
                    ClmNum = null;
                    MemNum = sessionInfo.SessionObject().ControlInfo.MemNum;
                    PracNum = sessionInfo.SessionObject().ControlInfo.PracNum;


                    RFSDateLog = null;
                    ReqBy = null;
                    RFSStatusCode =  sessionInfo.SessionObject().ControlInfo.RFSStatus;
                    RFSStatusAsAt = null;
                    AssignedTo = null;
                    RFSPriority =  sessionInfo.SessionObject().ControlInfo.RFSPriority;
                    CallSubCatCode = sessionInfo.SessionObject().ControlInfo.CallSubCat;
                    CallCatCode = sessionInfo.SessionObject().ControlInfo.CallCat;
                    CallerCatCode = sessionInfo.SessionObject().ControlInfo.CallerCat;
                    CallChannelCode = sessionInfo.SessionObject().ControlInfo.CallChannel;
                    WrkBasketCode =  sessionInfo.SessionObject().ControlInfo.WorkBasket;
                    Descr = tb_RFSNote.Text;
                    RecvDate = DateTime.Now;
                    CallNum = null;
                    UserName = sessionInfo.SessionObject().CurrentUser.UserName;

                    IList<RFSService.usp_w_Create_RFSLog_For_User_Result> CreatedResult = BusObject.CreatRFSForUser(RFSLogNum, CaseNum, ClmNum, MemNum, PracNum, RFSDateLog, ReqBy, RFSStatusCode, RFSStatusAsAt,
                                                        AssignedTo, RFSPriority, CallSubCatCode, CallCatCode, CallerCatCode, CallChannelCode, WrkBasketCode,
                                                        Descr, CallNum, RecvDate, UserName);

                    if (CreatedResult.Count > 0)
                    {

                        if (CreatedResult[0].ReturnCode > 0)
                        {
                            sessionInfo.SessionObject().ControlInfo.RFSLogNum = Convert.ToInt32(CreatedResult[0].ReturnCode);
                            //Attach documents

                            List<string> AttachResult = CreateAttachment();

                           
                            tbOKMessage.Text = CreatedResult[0].ReturnReason + "(" + CreatedResult[0].ReturnCode.ToString() + ")" ;

                            foreach (string tline in AttachResult)
                            {
                                tbOKMessage.Text = tbOKMessage.Text + " NB! - " + tline;
                            }

                            MPESuccess.Show();

                        }
                        else
                        {
                            tbOKMessage.Text = CreatedResult[0].ReturnReason + "(" + CreatedResult[0].ReturnCode.ToString() + ")";
                            MPEError1.Show();
                        }
                    }
                    else
                    {


                    }


                    break;
                case ("RFS"):
                    break;
            }

        }

        protected bool validateAction()
        {

            bool lbReturn = true;

            //Check if documents were selected


            //if (sessionInfo.SessionObject().ControlInfo.CallNum == null || (sessionInfo.SessionObject().ControlInfo.CallNum != null && sessionInfo.SessionObject().ControlInfo.CallNum == 0))
            //{
            //    umb_processmessage.PopulatedUserMessageControl(UserMessageIcons.USERMESSAGE_ERROR_ICON.ToString(), "The call header has not been processed yet!");
            //    lbReturn = false;
            //    return lbReturn;
            //}


            //if (tb_RFSNote.Text == null || tb_RFSNote.Text.Trim() == "")
            //{
            //    umb_Note.PopulatedUserMessageControl(UserMessageIcons.USERMESSAGE_ERROR_ICON.ToString(), "Please enter a note for this action");
            //    lbReturn = false;
            //}


            //if (ddl_RFSStatus.SelectedIndex < 0)
            //{
            //    umb_status.PopulatedUserMessageControl(UserMessageIcons.USERMESSAGE_ERROR_ICON.ToString(), "Please select a status for this action");
            //    lbReturn = false;
            //}

            //if (ddl_WrkBasket.SelectedIndex < 0)
            //{
            //    umb_wrkbasket.PopulatedUserMessageControl(UserMessageIcons.USERMESSAGE_ERROR_ICON.ToString(), "Please select a work basket for this action");
            //    lbReturn = false;
            //}

            //if (ddl_RFSPriority.SelectedIndex < 0)
            //{
            //    umb_priority.PopulatedUserMessageControl(UserMessageIcons.USERMESSAGE_ERROR_ICON.ToString(), "Please select a work basket for this action");
            //    lbReturn = false;
            //}


            return lbReturn;
        }

        protected void btnYes_Click(object sender, EventArgs e)
        {
            ControlInfo controlinfo = new ControlInfo();
            ControlInfo lookupinfo = new ControlInfo();

            sessionInfo.SessionObject().ControlInfo = controlinfo;


            Session.Remove("CallNum");

            sessionInfo.SessionObject().DynamicUserControlList = null;
            DynamicUserControlHelper dynamicUserControlHelper = new DynamicUserControlHelper();
            dynamicUserControlHelper.PopulateUserControlToSession("CORE");
            sessionInfo.SessionObject().LookupOrigin = "NewSession"; 
            Response.Redirect("../Screens/CubedNoHeader.aspx?ProcessID=CLSCN"); 
        }

        protected void btnNo_Click(object sender, EventArgs e)
        {
            Session.Remove("CallNum");
            ControlInfo controlinfo = new ControlInfo();
            ControlInfo lookupinfo = new ControlInfo();

            sessionInfo.SessionObject().ControlInfo = controlinfo;

            sessionInfo.SessionObject().DynamicUserControlList = null;
            DynamicUserControlHelper dynamicUserControlHelper = new DynamicUserControlHelper();
            Response.Redirect("../SecureHome.aspx");
        }

        protected void endBtn_Click(object sender, EventArgs e)
        {

        }

        protected void endnewbtn_Click(object sender, EventArgs e)
        {

        }

        protected void cancelBtn_Click(object sender, EventArgs e)
        {

        } 

        protected void rgFiles_PreRender(object sender, EventArgs e)
        {
            if (rgFiles.Items.Count > 0)
            {
                UpdatePanel2.Visible = true;
            }
            else
            {

                UpdatePanel2.Visible = false;
            }
        }

        protected void rcbDocSect_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {

            sessionInfo.SessionObject().ControlInfo.DocSect = e.Value; 
        }

        protected void rcbDocSubSect_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {

            sessionInfo.SessionObject().ControlInfo.DocSubSect = e.Value; 
        }

        protected void ddl_CallerCat_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        { 
            sessionInfo.SessionObject().ControlInfo.CallerCat  = e.Value; 
        }

        protected void ddl_CallCat_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        { 
            sessionInfo.SessionObject().ControlInfo.CallCat = e.Value; 
        }

        protected void ddl_CallSubCat_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            sessionInfo.SessionObject().ControlInfo.CallSubCat = e.Value;
        }

        protected void ddl_CallChannel_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            sessionInfo.SessionObject().ControlInfo.CallChannel = e.Value; 
        }

        protected void ddl_WrkBasket_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        { 
            sessionInfo.SessionObject().ControlInfo.WorkBasket = e.Value; 
        }

        protected void ddl_RFSPriority_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            sessionInfo.SessionObject().ControlInfo.RFSPriority = Convert.ToDecimal(e.Value);  
        }

        protected void ddl_RFSStatus_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            sessionInfo.SessionObject().ControlInfo.RFSStatus = e.Value; 
        }

        public List<string> CreateAttachment()
        {
            
            List<string>           DocsCreated = new List<string>();

            string DocType      = null; 
            string FileName     = null; 
            string Descr        = null; 
            DateTime? RecvDate  = DateTime.Today;
            bool?  RecvInd      = true; 
            string DocSect      = sessionInfo.SessionObject().ControlInfo.DocSect; 
            string DocSubSect   = sessionInfo.SessionObject().ControlInfo.DocSubSect;
            bool? CaseLog       = false; 
            Decimal?   CaseNum  = null; 
            bool? PracLog       = true; 
            Decimal? PracNum    = sessionInfo.SessionObject().ControlInfo.PracNum;
            bool? MemLog        = true;              
            int? MemNum         = sessionInfo.SessionObject().ControlInfo.MemNum;
            bool? GrpLog        = false; 
            int? GrpNum         = null;  
            bool? ClmLog        = false;  
            Decimal? ClmNum     = null; 
            bool? BrokerLog     = false; 
            int? BrokerNum      = null;  
            bool? RFSLog        = true; 
            Decimal? RFSLogNum  = sessionInfo.SessionObject().ControlInfo.RFSLogNum;
            bool? BrokerFirmLog = null; 
            int? BrokerFirmNum  = null; 
            byte[] FileSource   = null; 

     
           
            DataTable tb = GetDataTable;

            foreach (DataRow r in tb.Rows)
            {
                DocType = r.ItemArray[3].ToString().Trim();
                Descr =  r.ItemArray[1].ToString(); 
                FileSource = null; 

                    IList<RFSService.usp_w_Create_RFS_Attachments_Result> AttCreatedResult = BusObject.CreateRFSAttachment(DocType, FileName, Descr, RecvDate, RecvInd, DocSect,
                                                                DocSubSect, CaseLog, CaseNum, PracLog, PracNum, MemLog,
                                                                MemNum, GrpLog, GrpNum, ClmLog, ClmNum, BrokerLog, BrokerNum,
                                                                RFSLog, RFSLogNum, BrokerFirmLog, BrokerFirmNum, FileSource);
                    if (AttCreatedResult.Count > 0)
                    {
                         
                        if (AttCreatedResult[0].ReturnCode > 0)
                        {
                            decimal DocNum = AttCreatedResult[0].ReturnCode.GetValueOrDefault();

                            FileSource = (byte[])r.ItemArray[0];

                            IList<JasperService.usp_w_CreateSource_Result> SrcResult = BusObject.CreateSource(DocNum, FileSource);

                            if (SrcResult.Count > 0)
                            {
                                if (SrcResult[0].ReturnCode > 0)
                                {
                                    DocsCreated.Add("Successfully created attachment with Document # : " + ((int)AttCreatedResult[0].ReturnCode).ToString());
                                }
                                else
                                {

                                    DocsCreated.Add("DocMast entry created but could not set source of attachment with description : " + Descr + " " + AttCreatedResult[0].ReturnReason);
                                    return DocsCreated;
                                }
                            }
                            else
                            {
                                DocsCreated.Add("Could not create attachment with description : " + Descr + " " + AttCreatedResult[0].ReturnReason);
                                return DocsCreated;
                            }

                        }
                        else
                        {

                            DocsCreated.Add("Could not create attachment with description : " + Descr + " " + AttCreatedResult[0].ReturnReason);
                            return DocsCreated;
                        }
                    }
                    else
                    {
                        DocsCreated.Add("Could not create attachment with description : " + Descr);
                        return DocsCreated;
                    }

            }


            return DocsCreated;

        }
 

    }
}





















0
Accepted
Angel Petrov
Telerik team
answered on 10 Oct 2014, 05:47 AM
Hello Marius,

The implementation seems correct with one slight exception. The AJAX is not configured correctly. Note that is not recommended to nest update panel in a manner like the desribed as the most outer panel will handle the postback. Moreover in such cases there is not need to add a RadAjaxManager as the content of the page is already ajaxifyed. Pelase remove all RadAjaxManager and all update panels except the UpdatePanel1 panel and test whether this resolves the problem.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Marius
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Marius
Top achievements
Rank 1
Share this question
or