I have few text boxes and one RadAsyncUpload in the form.
When the form is submitted i am validating the text boxes in the server side and showing the validation message.
when the validation message box is shown, The RadAsyncupload controls is getting cleared.
I want to have the radAsyncUpload Control values to be persisted for the subsequent submit.
Thanks
9 Answers, 1 is accepted
You can use the AsyncUpload's PostBackTriggers property to persist the selected file across postbacks. The following documentation article explains this functionality in more detail.
Regards,
Ivan Danchev
Telerik
Hi,
I have similiary the same problem.
In my page i have a grid with manual update and delete comands that go to the server and do their proper things.
The problem is, every time i go to the server and back (without using the radAsyncUpload) the RadAsyncUpload gets hidden/cleared.
I have set the PostBackTriggers to a button in my page that deals with the reading of the files. But it doesn't solve.
At this time i am not looking to preserve the files (cause im not even using the RadAsyncUpload).
I just want to preserve the RadAsyncUpload itself.
Adding another information. After this happend i go to see the source code of the page, and the input of the RadAsyncUpload is type="hidden".
Can anyone help me?
How is the AsyncUpload related to the Grid in your scenario? Are you using it in an EditItemTemplate as shown below, or in a different way?
<
telerik:GridTemplateColumn
DataField
=
"Data"
HeaderText
=
"Image"
UniqueName
=
"Upload"
>
<
EditItemTemplate
>
<
telerik:RadAsyncUpload
RenderMode
=
"Lightweight"
runat
=
"server"
ID
=
"AsyncUpload1"
AllowedFileExtensions
=
"jpg,jpeg,png,gif"
>
</
telerik:RadAsyncUpload
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
Regards,
Ivan Danchev
Telerik by Progress
Hi Ivan,
No. My AsyncUpload is outside the grid. It is used as a alternative way to fill the grid.
Below is part of my page' code. Hope it can help.
Thanks is advance,
João Pedro
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
DefaultLoadingPanelID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"grdProcessosLiquidados"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"grdProcessosLiquidados"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadWindowManager1"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadInputManager1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadSkinManager
ID
=
"RadSkinManager1"
runat
=
"server"
></
telerik:RadSkinManager
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
AsyncPostBackTimeout
=
"600"
>
<
Scripts
>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.Core.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQuery.js"
/>
<
asp:ScriptReference
Assembly
=
"Telerik.Web.UI"
Name
=
"Telerik.Web.UI.Common.jQueryInclude.js"
/>
</
Scripts
>
</
telerik:RadScriptManager
>
<
telerik:RadFormDecorator
ID
=
"RadFormDecorator1"
runat
=
"server"
DecoratedControls
=
"All"
DecorationZoneID
=
"decorationZone"
EnableRoundedCorners
=
"false"
/>
<
telerik:RadAjaxPanel
ID
=
"RadAjaxPanel1"
runat
=
"server"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
>
<
telerik:RadScriptBlock
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function KeyPress(sender, args) {
var c = args.get_keyCode();
if (c == 13) {
__doPostBack('btnKeyPress', '');
}
}
function rowDblClick(sender, eventArgs) {
sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
}
</
script
>
</
telerik:RadScriptBlock
>
<
div
class
=
"fieldset-page"
>
<%-- someFields --%>
<
telerik:RadGrid
ID
=
"grdProcessosLiquidados"
runat
=
"server"
OnDeleteCommand
=
"grdProcessosLiquidados_DeleteCommand"
OnItemCreated
=
"grdProcessosLiquidados_ItemCreated"
OnUpdateCommand
=
"grdProcessosLiquidados_UpdateCommand"
AllowMultiRowSelection
=
"True"
OnItemDataBound
=
"grdProcessosLiquidados_ItemDataBound"
AutoGenerateColumns
=
"false"
Width
=
"1055px"
OnNeedDataSource
=
"grdProcessosLiquidados_NeedDataSource"
AllowPaging
=
"true"
AllowSorting
=
"true"
ShowGroupPanel
=
"false"
Skin
=
"Office2010Silver"
>
<
ClientSettings
AllowKeyboardNavigation
=
"true"
>
<
Selecting
AllowRowSelect
=
"True"
/>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"false"
/>
<
ClientEvents
OnRowDblClick
=
"rowDblClick"
/>
</
ClientSettings
>
<
HeaderStyle
HorizontalAlign
=
"Center"
VerticalAlign
=
"Middle"
Wrap
=
"false"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
VerticalAlign
=
"Middle"
Wrap
=
"false"
/>
<
AlternatingItemStyle
HorizontalAlign
=
"Center"
VerticalAlign
=
"Middle"
/>
<
EditItemStyle
HorizontalAlign
=
"Center"
Wrap
=
"false"
VerticalAlign
=
"Middle"
/>
<
MasterTableView
EditMode
=
"InPlace"
>
<
Columns
>
<
telerik:GridEditCommandColumn
ButtonType
=
"FontIconButton"
/>
<
telerik:GridButtonColumn
ConfirmTitle
=
"Delete"
ButtonType
=
"FontIconButton"
CommandName
=
"Delete"
/>
<
telerik:GridBoundColumn
DataField
=
"NumeroProcesso"
FilterControlAltText
=
"Filter NumeroProcesso column"
HeaderText
=
"Nº Processo"
SortExpression
=
"NumeroProcesso"
UniqueName
=
"NumeroProcesso"
>
<
ColumnValidationSettings
>
<
ModelErrorMessage
Text
=
""
/>
</
ColumnValidationSettings
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Nome"
FilterControlAltText
=
"Filter Nome column"
HeaderText
=
"Nome Cliente"
SortExpression
=
"Nome"
UniqueName
=
"Nome"
>
<
ColumnValidationSettings
>
<
ModelErrorMessage
Text
=
""
/>
</
ColumnValidationSettings
>
</
telerik:GridBoundColumn
>
<%-- someMoreColumns --%>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
div
class
=
"fieldset-cell"
style
=
"width:300px"
>
<
telerik:RadLabel
ID
=
"lblFicheiro"
runat
=
"server"
AssociatedControlID
=
"brwFicheiro"
Text
=
"Ficheiro:"
CssClass
=
"shortLabel"
></
telerik:RadLabel
>
<
telerik:RadAsyncUpload
ID
=
"brwFicheiro"
runat
=
"server"
MaxFileInputsCount
=
"1"
HideFileInput
=
"false"
PostbackTriggers
=
"btnImportar"
>
</
telerik:RadAsyncUpload
>
</
div
>
</
div
>
</
telerik:RadAjaxPanel
>
<
telerik:RadInputManager
ID
=
"RadInputManager1"
Skin
=
"Office2010Silver"
runat
=
"server"
Enabled
=
"true"
>
<
telerik:NumericTextBoxSetting
BehaviorID
=
"NumeroProcessoSetting"
Type
=
"Number"
DecimalDigits
=
"0"
AllowRounding
=
"true"
></
telerik:NumericTextBoxSetting
>
<
telerik:TextBoxSetting
BehaviorID
=
"NomeSetting"
></
telerik:TextBoxSetting
>
</
telerik:RadInputManager
>
<
telerik:RadWindowManager
ID
=
"RadWindowManager1"
runat
=
"server"
></
telerik:RadWindowManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
></
telerik:RadAjaxLoadingPanel
>
Based on the provided information I think there could be two reasons for the AsyncUpload not being visible after a postback:
- A javascript error on the page that prevents the AsyncUpload from being properly initialized and rendered. You can check for such errors in the browser dev tools console.
- Updating the same controls with AjaxManager and an AjaxPanel at the same time. This a scenario that must be avoided as mentioned in this article, as it could lead to unexpected/unwanted behavior. In your case the Grid (grdProcessosLiquidados) is added to the AjaxManager's settings, but at the same time it (as well as the AsyncUpload) is wrapped in an AjaxPanel:
<
telerik:RadAjaxPanel
ID
=
"RadAjaxPanel1"
runat
=
"server"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
>
Remove the AjaxPanel and check whether this fixes the issue with the AsyncUpload's visibility.
Regards,
Ivan Danchev
Telerik by Progress
Hi Ivan,
The 2nd case was the solution!! Thank you very much for the help ;)
Regards,
João Pedro
Updating a control with AjaxManager and AjaxPanel/UpdatePanel at the same is a common mistake. I am glad the issue is fixed.
Regards,
Ivan Danchev
Telerik by Progress