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

radasyncupload loses files on postback

2 Answers 563 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jayesh Goyani
Top achievements
Rank 2
Jayesh Goyani asked on 14 Mar 2011, 09:24 AM
hi,
when i select the item from RadCombo at that time i want to change lable text.
i select a file in Radasyncupload then i change the another item from combo at that time the which was selected in radasyncupload it was lost after Radcombo's postback fired.
 
plz see my code for more information..
<div>
        <telerik:RadAjaxManager ID="RadAjaxManager2" runat="server" ClientEvents-OnRequestStart="conditionalPostback">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="rgInquiry">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="rgInquiry" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <telerik:RadCodeBlock ID="RadCodeBlock2" runat="server">
            <script type="text/javascript">
        // <![CDATA[
                //On insert and update buttons click temporarily disables ajax to perform upload actions
                function conditionalPostback(sender, eventArgs) {
                    var theRegexp = new RegExp("\.UpdateButton$|\.PerformInsertButton$", "ig");
                    if (eventArgs.get_eventTarget().match(theRegexp)) {
                        var upload = $find(window['UploadId']);
 
                        //AJAX is disabled only if file is selected for upload
                        if (upload.getFileInputs()[0].value != "") {
                            eventArgs.set_enableAjax(false);
                        }
                    }
                }
 
                function validateRadUpload(source, e) {
                    e.IsValid = false;
 
                    var upload = $find(source.parentNode.getElementsByTagName('div')[0].id);
                    var inputs = upload.getFileInputs();
                    for (var i = 0; i < inputs.length; i++) {
                        //check for empty string or invalid extension
                        if (inputs[i].value != " " && upload.isExtensionValid(inputs[i].value)) {
                            e.IsValid = true;
                            break;
                        }
                    }
                }
            // ]]>
            </script>
        </telerik:RadCodeBlock>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel2" runat="server" />
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" AllowSorting="True"
            AllowPaging="True" PageSize="10" GridLines="None" OnUpdateCommand="rgInquiry_ItemUpdated"
            OnItemCommand="rgInquiry_ItemCommand" OnDeleteCommand="rgInquiry_ItemDeleted"
            OnCancelCommand="rgInquiry_CancelCommand" OnInsertCommand="rgInquiry_ItemInserted"
            AllowFilteringByColumn="true" OnNeedDataSource="rgInquiry_NeedDataSource" OnItemDataBound="rgInquiry_ItemDataBound"
            OnItemCreated="rgInquiry_ItemCreated">
            <MasterTableView CommandItemDisplay="Top" DataKeyNames="InquiryID" AllowMultiColumnSorting="True"
                GroupLoadMode="Server" CommandItemSettings-AddNewRecordText="Add New Inquiry">
                <Columns>
                </Columns>
                <EditFormSettings ColumnNumber="2" CaptionFormatString="Add/Edit properties of Inquiry : "
                    EditFormType="Template">
                    <FormTemplate>
                        <div>
                            <telerik:RadComboBox ID="rcbClientNew" runat="server" Width="300px" EmptyMessage="Select Client"
                                DataTextField="ClientID" Filter="Contains" AllowCustomText="true" AutoPostBack="true"
                                OnSelectedIndexChanged="rcbClient_SelectIndexChanged" CausesValidation="false">
                            </telerik:RadComboBox>
                            <asp:Label ID="lblClientName" SkinID="LabelU" runat="server">
                                <br />
                                <asp:Label ID="Label1" SkinID="LabelU" runat="server" Text="Attach File: "> </asp:Label>
                                <telerik:RadProgressManager ID="radProgreesManager1" runat="server" EnableTheming="true" />
                                <telerik:RadAsyncUpload runat="server" ID="AsyncUpload1" MultipleFileSelection="Automatic">
                                </telerik:RadAsyncUpload>
                                <telerik:RadProgressArea ID="radProgressArea1" runat="server" EnableTheming="true">
                                </telerik:RadProgressArea>
                                <br />
                                <div class="DynButton">
                                    <asp:Button ID="btnParentSubmit" runat="server" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                        CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>' />
                                </div>
                                <div class="DynButton">
                                    <asp:Button ID="btnPatentReset" runat="server" Text="Cancel" CausesValidation="false"
                                        CommandName="Cancel" />
                                </div>
                        </div>
                    </FormTemplate>
                </EditFormSettings>
            </MasterTableView>
        </telerik:RadGrid>
    </div>

Thanks,
Jayesh Goyani

2 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetina
Telerik team
answered on 17 Mar 2011, 10:28 AM
Hello Jayesh,

This is expected behavior of RadAsyncUpload since when the postback from the combo happens, it uploads the file selected.

In case you want to handle this scenario in a more user-friendly way you can wire the OnFileUploaded server-side event of the async upload control and display some message in the edit form which indicates that the file has already been uploaded. This event will be fired in the same postback as the SelectedIndexChanged event of the combobox.

Kind regards,
Tsvetina
the Telerik team
0
Jayesh Goyani
Top achievements
Rank 2
answered on 19 Mar 2011, 12:34 PM
hi Tsvetina ,
thanx for your help.

thanks,
Jayesh Goyani
Tags
Grid
Asked by
Jayesh Goyani
Top achievements
Rank 2
Answers by
Tsvetina
Telerik team
Jayesh Goyani
Top achievements
Rank 2
Share this question
or