Web.zipI am working on the module that does upload data, without storing file on the server, in the WebForm environment utilizing WebUpload control. In general it is working..
Have several questions:1.I am getting texts on the buttons as following : after load I see "Upload File" then "Upload" and after it done - "Add" .... How do I change text on them ?
2. I added <div id="uploadErrors" style="color: red;"></div> and <AllowedExtensions>, when I am trying to add file with wrong extension it does not show upload button but it does not show error message in red either.. How to make message visible
3. How to make Clear Upload button visible.
4. In the document on the site there is following example adding server events :
<system.web><pages><add tagPrefix="igjq" namespace="Infragistics.Web.UI.EditorControls"assembly="Infragistics.Web.jQuery"/></pages></system.web><igjq:WebUpload ID="webUpload1" runat="server"OnUploadFinishing="webUpload1_OnUploadFinishing"OnUploadFinished="webUpload1_OnUploadFinished"OnUploadStarting="webUpload1_OnUploadStarting"></igjq:WebUpload>
On the other hand I just added protected void WebUpload1_UploadFinishing(object sender, Infragistics.Web.UI.EditorControls.UploadFinishingEventArgs e) and it is working, what is the difference ?
Files added for references, please show fixes in FileUpload01when possible...
Hello Michael,
After investigating this further, I determined that the labels of the buttons could be customized by using the Locales-LabelUploadButton, Locales-LabelAddButton and Locales-LabelSummaryProgressButtonContinue properties of the WebUpload:
<ig:WebUpload ID="WebUpload1" runat="server . . . Locales-LabelUploadButton="myUpload" Locales-LabelAddButton="myAdd" Locales-LabelSummaryProgressButtonContinue="myUploadStart">
The clear button could be displayed by setting the mode of the WebUpload to multiple. Additionally if the WebUpload should allow only one image, MaxUploadedFiles property could be set to 1.
Regarding your second requirement, a method could be bound to the onError client side event, where the innerHtml of the div could be set to the error message. The method would look as follows:
var div = document.getElementById("uploadErrors");
function error(sender, args) {
div.innerHTML = args.errorMessage;
}
In regards to the WebUpload events our sample implements handlers for both OnUploadStarting, OnUploadFinishing and OnUploadFinished. They are implemented for the purposes of this particular sample, however it is not necessary to always include them in order to have your WebUpload control working. In case that you need one or more of them the essential part is to have them included in the tag for the web upload and to have handlers on the server side. By default, handler names are created as following: ControlID_EventName. For example: webUpload1_OnUploadFinishing However, if you would like to change this name you can assign any name of your choice, as I believe is the case with WebUpload1_UploadFinishing.
Below I am attaching a sample, demonstrating customizing the labels. Please test it on your side and let me know if you need any further information regarding this matter.
Regards, Monika Kirkova, Infragistics
WebUploadSaveFile.zip
Hi Monika,
Thanks for the help, It is still work in progress.. I have another issue that I need to resolve, It is somehow related to the way control operates.. After I've read the stream ( string xmlDt = impOS.ReadLR4OneSourceSpreadsheet(e.FileStream); ) I do some data save and then has to seamlessly transfer to other page that does processing and representation.. The upload control while sending file to the server does not cause page to postback... so there is seems like no lifecycle page events where I can put Server.Transfer request and naturally if I would put it into UploadFinishing event like below I will get {"Error executing child request for Uno.aspx."}, because it is apparently wrong context.. Would you advise how to deal with transfer in the WebForm environment while using this control for Upload.. The transfer is needed right after file read in the UploadFinishing event..
protected void WebUpload1_UploadFinishing(object sender
, nfragistics.Web.UI.EditorControls.UploadFinishingEventArgs e) { LR4OneSourceImport impOS = new LR4OneSourceImport(); string xmlDt = impOS.ReadLR4OneSourceSpreadsheet(e.FileStream); // e.Cancel = true; Server.Transfer("Uno.aspx", true); }
Thanks.
Couple more of them...
1. I need add warning that data will be overridden.. so I added WebUpload1_FileUploading like that:
function WebUpload1_FileUploading(eventArgs, infoObject) { if (confirm("Continue will override existing data")) return true; else return false
The issue is if I choose cancel, it does cancel - so it works fine.. but it I choose 'OK' means continue, it asks again and only after second 'OK' continue with upload.. why is that.. one 'ok' should be enough
2. Multiple files approach for clear button make things awkward.. so I noticed that even in single file case it has the little square on the upper right corner that actually has tool tip 'cancel' -- any way to add little 'x' sign to that.. (see the image)
3. Is there a way to make progress bar to move slower.. and/or controls it somehow..
FileUpload01.aspx.zip
It looks like there is some issue with the FileUploading event and it fires twice. You can workaround that by using a boolean var that shows if you've already handled it for this cycle like this:
var uploadingFlag = false; function WebUpload1_FileUploading(eventArgs, infoObject) { if (uploadingFlag) { uploadingFlag = false; return; } uploadingFlag = true; if (!confirm("Continue will override existing data")) { return false; } }
I've logged the issue in our internal system with ID 272025 and created a private support case on your behalf - CAS-210596-J0S1Y5. I've linked the issue with your case so that you will receive updates about its development.
Regarding the second question - there are icons in these places. My assumption is that they are not available because you are missing some part of the css folder structure. Please, ensure that you've copied the entire C:\Program Files (x86)\Infragistics\2020.1\ASP.NET\jQuery\css directory to the directory you are referring in your app.
As for the progress updates - you've already defined a http handler in your web.config so you may add it as a progress URL - ProgressUrl="/WebUploadStatusHandler.ashx". Please, check if that solves the issue.
I hope this helps! Please, let me know if I may help you further!
Best regards,
Stamen Stoychev
Hello, thanks for your help.. the work around seems working.. but here is another issue beyond it..
Here what I am doing : I am picking up excel spreadsheet and processing it in WebUpload1_UploadFinishing on the server where it is available as a Stream (e.FileStream), Processing includes back end update.. all works well right inside WebUpload1_UploadFinishing server event...
Here is the problem: Before starting Upload I need to warn user that the process wiping out existing data and give him a choice to proceed or cancel.. and to that end I though to use WebUpload1_FileUploading on the client which is supposed to be cancellable.. and for that I used confirm prompt with approach that you advised.. The issue is when confirm prompt is raised, it does not matter if I choose ok or cancel because at that point WebUpload1_UploadFinishing and WebUpload1_UploadFinished are both fired and executed already and database is updated and confirm request does not make any sense.. Any advise how to interrupt process so user can cancel upload before it happened... Attaching latest version of my sample file.. it is running version, if you can show how to deal with this issued in it.
4478.FileUpload01.aspx.zip
I guess if nothing else, like attach somehow click event to the uploadStart button (2nd phase), I can put confirm to FileSelecting event..
I am sorry for the delayed response!
I had to dig in a bit deeper but you are right, the FileUploading event cannot really be used to cancel uploads on user request as it is fired during the uploading progress, after the request has already been made. It could work for larger files where the user has some time to decide but it's overall better to use FileSelected.
Alternatively, if FileSelected doesn't meet your UX requirements, I can create a workaround hijacking the click event on Upload button so that you can hook to it. Let me know if you prefer that.
FileSelecting
Hi Stamen.. FileSelected works fine. Thanks for your help.