Calling Uploader.UploadFiles on mobile device

Answered
0
0

Hi.

I have a HIDDEN Uploader control and call its UploadFiles from another button, for some reasons. It works perfectly on the desktop, but not in an actual cell phone. Apparently, when we use the Uploader control itself in a Phone, it triggers something that makes the phone OS to display a Dialog first, asking the source from where we want to list the files to be chosen. But it looks like calling the Uploader.UploadFiles directly skips this step and the phone just doesn’t show anything.

Would you guys know of a way I could make a call to the Hidden UploadControl that would work on the Phone too?

Thanks in advance.

Ivan

  • You must to post comments
Great Answer
0
0

Usually that means that the browser blocks the ajax action and it has to be initiated by a user action. In this case instead of calling upload.UploadFiles() from the server, add a “execute” (or “tap”) client event to the other button and call the upload files method in javascript. You need the reference to the hidden upload control. You can reach it using App with the full path, like this:

"App.MainPage.upload1.upload();"

Otherwise you can assign the reference:

this.button1.Call("this.setUserData", "uploadControl", this.upload1);

this.button1.AddClientEventListener("execute", "this.getUserData('uploadControl').upload();");

Or something like this. It used to be that chrome on desktop also didn’t allow for non-user initiated code to invoke the upload.

 

 

 

  • You must to post comments
0
0

Hi Luca.

Thanks for the explanation. I was on the right path, I guess, but I went from the Form object straight to the Button, and skipped the Panel, GroupBox, etc.

On the Uploader Theme, it means then that there is no way to apply an Appearance key directly to the Button, right? I thought it would be possible reading one of your answers on the forum ( https://wisej.com/support/question/upload-files-not-working-on-firefox ). Sorry if I am making a confusing out of it. 🙂

  • Luca (ITG)
    The button is “button” at this.upload1.getChildControl(“button”). You can change the appearance using this.upload1.Eval(“this.getChildControl(‘button’).setAppearance(‘test’)); In Wisej the widgets are a single component for the server and the internal UI is all managed on the client. All widgets are composites or child widgets.
  • Ivan Borges
    Thank you again Luca for the patience. I guess I will let this behind since I got it working with your previous advice. However, I have put this.btnLogoUploader.Eval(“this.getChildControl(‘button’).setAppearance(‘button-cancel’)”); in the Form_Load, Form_Appear, and nothing happened. Maybe “button” is not a Child Control.
  • You must to post comments
0
0

The object model is the same as in your app using the names of the controls. The main page is App.MainPage. The desktop is App.Desktop, each floating window is App.[window name]. If there are multiple with the same name it’s an array. I.e. App.frm1.panel1.groupbox1.textbox1.

You can pass controls to javascript as parameters and Wisej will marshal it back and forth. I.e. this.Call(“doSomethingWithButton”, this.button1); will call doSomethingWithButton(button) on the client where “button” is the client widget that corresponds to the server control.

You can also get an object by id using the Control.Handle. That is the unique id of the control also on the client (with the “id_” prefix).

The Upload control is not a button, it’s a composite widget with a textfield and a button and a container. See below. The native upload <input> cannot be styled.

 

Attachment
  • You must to post comments
0
0

Hi Luca.

I now used your second advice and it worked perfectly. Nevertheless, if you could give me some tips on how to properly find out the Object Model full path to be able to use the Client Event as you described, it would be great.

By the way, the main reason I am going through all this is because I wanted the Uploader to show its button with the same Theme as the other buttons in the form. Changing its AppearanceKey showed it properly at Design Time, but once I run the application, the button shows all messed up.

Cheers.

Ivan

  • You must to post comments
0
0

Thank you Luca!

I am trying to implement your first option, and as dumb as I am in dealing with JavaScript I am having a hard time to reach the upload(). By the way, it is uploadFiles(), isn’t it? Anyway, I probably am entering the wrong Object Model in the Call. Looking at the Documentation, I saw that we can go to F12 in Chrome and filter the Console with “App.”. Doing that, I can find as far as the Form object, not able to see any of its controls. Even though, I have tried:

App.MyForm.MyUploaderButton.upload();

App.MyForm.MyUploaderButton.uploadFiles();

Both throw an error, saying “Uncaught TypeError: Cannot read property ‘upload’ (or ‘uploadFiles’) of undefined”

Would you guess what I am doing wrong?

  • You must to post comments
Showing 5 results
Your Answer

Please first to submit.