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.
Also Server.Transfer is a preferred way as I'll be reading some XML data stored in the first page with the upload control...
And also while trying to gain more understanding how control works and what options are :
if I add event :
function WebUpload1_FileUploaded(eventArgs, infoObject){ //Add code to handle your event here. var loc = $("#hdnSiteRootUrl").val(); alert(loc); window.location.replace(loc);}
it will redirect to the next page.. the only thing I want to understand is the following.. if I assign value to the hidden variable during some page lifecycle events e.g. Page_Load (hdnSiteRootUrl.Value = "https://localhost:44319/Uno.aspx";) - it will work, if I would assign value to the hdnSiteRootUrl in WebUpload1_UploadFinishing or WebUpload1_UploadFinished then in WebUpload1_FileUploaded hdnSiteRootUrl will be "Original" i.e. initial value .. I wonder why...
<input id="hdnSiteRootUrl" runat="server" type="hidden" value="Original" />
The error message is being displayed because the file is not fully uploaded when the server tries to redirect. However, by binding a method to the client side fileUploaded event, as stated in your latest response, the file is already loaded and the page could be redirected.
Regarding your second question, the new value of the hidden input could be sent to the client side using the event server message. This could be achieved as follows:
protected void WebUpload1_UploadFinished(object sender, Infragistics.Web.UI.EditorControls.UploadFinishedEventArgs e)
{
e.ServerMessage += "">localhost:50313/Default2.aspx";
function fileUploaded(sender, args) {
$("#hdnSiteRootUrl").val(args.fileInfo.serverMessage);
var loc = $("#hdnSiteRootUrl").val();
window.location.replace(loc);
Please test it on your side and let me know if you need any further information regarding this matter.
Please note that due to the upcoming Christmas holidays you may experience slight delay in support responses.
Thank you for your understanding!
FileSelecting
Hi Stamen.. FileSelected works fine. Thanks for your help.
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.
Best regards,
Stamen Stoychev
I guess if nothing else, like attach somehow click event to the uploadStart button (2nd phase), I can put confirm to FileSelecting event..
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