Upload control's Visible property

Welcome to Wisej Support.
Questions, suggestions and plain old bugs - are all welcome here!
0
0

Hi,

Using the javascript code here in a button works fine the first time I click on the button. If I click it the second time choosing/uploading the same file, nothing happens. It works the second time if I choose a file different from the first one. Should it be the correct behavior?

If I set Visible property false, nothing happens and no error message is shown using Chrome, Edge, Firefox. In IE, I get

Unhandled exception at line 5, column 4 in eval code

0x800a138f – JavaScript runtime error: Unable to get property ‘upload’ of undefined or null reference

Is it not possible to set Visible=false?

Thanks.

 

  • You must to post comments
0
0

Hi Luca,

Using 1.2.37.0, both issues are now fixed.

Thanks.

  • You must to post comments
0
0

The unexpected token error looks like a syntax error in the javascript. Make sure that you are using the standard quotes in the assignment. If you copy/paste from wordpress you get the slanted quotes.

  • You must to post comments
0
0

Hi Luca,

Hidden upload control now works with your modified code. However, still no luck if I insert “this.uploadButton.__upload.value = “”;” for duplicate upload. I get “Invalid or unexpected token” message”.

Thanks.

  • You must to post comments
0
0

Found the issue. It is fixed in the current dev build.

The upload widget hooks the inner upload element when the widget is rendered (the dom element is created) the first time. When it’s not visible, even if created as a widget, the dom is not created and there is no upload element to use.

You can workaround this in your build by setting upload1.Visible = true add this.uploadButons.setOpacity(0) to make it invisible.

this.button1.Eval(
 String.Format(@"
     this.uploadButton = Wisej.Core.getComponent(""id_{0}"");
     this.uploadButton.setOpacity(0);

     this.addListener(""execute"", function(e)
     {{
        this.uploadButton.upload();
     }});", this.upload1.Handle));

 

It should work like this – except the duplicate upload. If you want to workaround the duplicate upload issue, change the handler like this:

 

this.addListener(""execute"", function(e)
     {{
        this.uploadButton.__upload.value = "";
        this.uploadButton.upload();

 }});", this.upload1.Handle));

Both issues are fixed in the current build coming up.

  • You must to post comments
0
0

Hi Luca,

Thanks but it doesn’t work either.

Your test project uses the second option you posted here but mine uses the javascript in a button. Also, my code explicitly specify the location where the uploaded file should be saved in. In your code, what is the default location of the uploaded file?

  • You must to post comments
0
0

Attached. Let me know if it doesn’t work for you and I will send you a link to the latest wisej dlls in case there is something new that fixed something else…

  • You must to post comments
0
0

Hi Luca,

I don’t get any error message even in IE 11 now. But in Chrome, after the form showed up, there is an error in Developer Tool like:

“Failed to load resource: net::ERR_CONNECTION_REFUSED”. I don’t know what that is.

Would you mind sending me or post your test project so I have something to compare with.

Thanks.

  • You must to post comments
0
0

Should be. Same error? When I tried here it worked – except for the duplicated upload.

  • You must to post comments
0
0

Hi Luca,

Thanks for immediate response. I put the code in Load event but still nothing happens. It is supposed to display the Open dialog window to select the file to be uploaded. Here is the code:

protected override void OnLoad(EventArgs e)
{
this.upload1.Visible = false;
this.upload1.CreateControl();
base.OnLoad(e);
}

Am I on the right spot?

Regards.

 

  • You must to post comments
0
0

Hi Cris,

This is probably caused by the latest optimization: controls are sent to the client only after they are shown the first time. This optimization has increased the rendering speed a lot especially when a form has multiple complex tab pages or panels that are shown at different times. You need to ensure that the invisible control is created using this.upload.CreateControl();

The other issue about not sending the same file twice is WJ-7499. It’s the upload element that needs to be reset to “”.

Best,

Luca

 

  • You must to post comments
Showing 10 results
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Attachment
File Name Size
There are currently no files uploaded.
Maximum number of files 5, maximum file size 3.9MB.
Supported file formats: zip pdf gif jpg bmp png cs vb theme json