after the AjaxfileUpload UploadComplete I need to change the text of a Literal inside the page accordingly to the outcome of the upload event. I can't use the usual grafical behaviour of the control because I have a custom check before the SaveAs method
(so the AjaxFileUpload could show to the user that the file is successfully uploaded when in fact it has never been saved).
The literal is already in an asp UpdatePanel. I have to force a postback after the UploadComplet event to refresh a gridView that is in the updatePanel.
However I tried to put my literal inside and outside the updatePanel and to change the text without forcing the postback, but the text never appeared.
marco_ked2
Member
7 Points
14 Posts
changing Literal after AjaxFileUpload UploadComplete
Nov 21, 2012 10:28 AM|LINK
Hi,
after the AjaxfileUpload UploadComplete I need to change the text of a Literal inside the page accordingly to the outcome of the upload event. I can't use the usual grafical behaviour of the control because I have a custom check before the SaveAs method (so the AjaxFileUpload could show to the user that the file is successfully uploaded when in fact it has never been saved).
There is a way to do so?
jagjot
Contributor
2648 Points
1229 Posts
Re: changing Literal after AjaxFileUpload UploadComplete
Nov 21, 2012 10:38 AM|LINK
have you tried
<ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload" runat="server" UploadedComplete="AjaxFileUploadUploadComplete" ThrobberID="MyThrobber" AllowedFileTypes=""MaximumNumberOfFiles="0" />
M.Sc, MIEEE, MCP, CCNA
marco_ked2
Member
7 Points
14 Posts
Re: changing Literal after AjaxFileUpload UploadComplete
Nov 21, 2012 11:16 AM|LINK
thanks for your reply
I use the OnUploadComplete event to do my custom check. UploadedComplete is never fired.
jagjot
Contributor
2648 Points
1229 Posts
Re: changing Literal after AjaxFileUpload UploadComplete
Nov 21, 2012 11:20 AM|LINK
can you post your code behind for the UploadComplete Event?
M.Sc, MIEEE, MCP, CCNA
marco_ked2
Member
7 Points
14 Posts
Re: changing Literal after AjaxFileUpload UploadComplete
Nov 21, 2012 11:48 AM|LINK
protected void AjaxFileUploadFile_UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e) { if (myCustomCheck()){ AjaxFileUploadFile.SaveAs(e.FileName); LiteralResponse.Text = "File saved"; } else { LiteralResponse.Text = "File not saved"; } }jagjot
Contributor
2648 Points
1229 Posts
Re: changing Literal after AjaxFileUpload UploadComplete
Nov 21, 2012 12:19 PM|LINK
can you try using label instead of literal control?
M.Sc, MIEEE, MCP, CCNA
marco_ked2
Member
7 Points
14 Posts
Re: changing Literal after AjaxFileUpload UploadComplete
Nov 21, 2012 04:16 PM|LINK
I tried to use label and nothing changed. I also tried to get with javascript the text of the label after the UploadComplete event but it's empty.
jagjot
Contributor
2648 Points
1229 Posts
Re: changing Literal after AjaxFileUpload UploadComplete
Nov 21, 2012 06:46 PM|LINK
can you post your html code. try putting your literal into ajax updatepanel.
M.Sc, MIEEE, MCP, CCNA
marco_ked2
Member
7 Points
14 Posts
Re: changing Literal after AjaxFileUpload UploadComplete
Nov 22, 2012 11:55 AM|LINK
The literal is already in an asp UpdatePanel. I have to force a postback after the UploadComplet event to refresh a gridView that is in the updatePanel.
However I tried to put my literal inside and outside the updatePanel and to change the text without forcing the postback, but the text never appeared.
<script type="text/javascript"> function ajaxFileUploadAttachments_ClientUploadComplete(sender, e) { var hidField = document.getElementById("<%=myHiddenField.ClientID %>"), hidVal = +hidField.value || 0; if (sender._filesInQueue[sender._filesInQueue.length - 1]._isUploaded) { __doPostBack('<%= UpdatePanelFileUploads.ClientID %>', hidVal); } } </script> <asp:UpdatePanel ID="UpdatePanelFileUploads" runat="server" UpdateMode="Conditional" OnLoad="UpdatePanelFileUploads_Load"><ContentTemplate> <asp:HiddenField ID="myHiddenField" runat="server" Value='<%# FieldValueEditString %>'></asp:HiddenField> <asp:PlaceHolder ID="PlaceHolderFiles" runat="server"> <asp:GridView PagerSettings-Visible="true" ID="GridViewFiles" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSourceFileCaricati" AlternatingRowStyle-CssClass="odd" HeaderStyle-CssClass="headerTable" CssClass="gridLight" ShowHeader="false" ondatabound="GridViewFiles_DataBound"> <Columns> </Columns> </asp:GridView> <asp:SqlDataSource ID="SqlDataSourceFileCaricati" runat="server" ConnectionString="<%$ ConnectionStrings:SoluzioneWebConnectionString %>" SelectCommand="" > </asp:SqlDataSource> </asp:PlaceHolder> <ajaxToolkit:AjaxFileUpload runat="server" ID="AjaxFileUploadFile" OnClientUploadComplete="ajaxFileUploadAttachments_ClientUploadComplete" OnUploadComplete="AjaxFileUploadFile_UploadComplete" /> <asp:Literal ID="LiteralMessaggioRisposta" runat="server"></asp:Literal> </ContentTemplate></asp:UpdatePanel>My code is a web user control for a fieldTemplate in a Dynamic Data web site.
jagjot
Contributor
2648 Points
1229 Posts
Re: changing Literal after AjaxFileUpload UploadComplete
Nov 22, 2012 12:36 PM|LINK
is you codebehind function firing at all?
M.Sc, MIEEE, MCP, CCNA