Upload files not working on Firefox

Answered
0
0

The following code is working on edge, chrome, IE, opera, but not on firefox or in older versions of chrome (on vista for example).

More specific, the push button do nothing. Please advice.

 

private void cmdAddFile_Click(object sender, EventArgs e)
{
Wisej.Web.Upload u = new Upload();
u.Uploaded += U_Uploaded;
u.AllowMultipleFiles = false;
u.AllowedFileTypes = “.pdf”;
u.UploadFiles();
}

private void U_Uploaded(object sender, UploadedEventArgs e)
{
string nf = …;
e.Files[0].SaveAs(nf);

….
}

  • You must to post comments
Best Answer
0
0

See attached.

  • You don’t need to set the CellTemplate, the DataGridViewButtonColumn already uses the correct template.
  • Buttons labeled “Except Firefox” work with Chrome, Edge and IE11.
  • Buttons labeled “Including Firefox” work on all browsers.
  • The first two columns are DataGridViewButtonColumn
  • The last two columns create a button control in each cell (not recommended)
  • Look at the ClientEvents collection in the DataGridView and the buttons labeled “Including Firefox.”
  • The expression “App.MainPage.upload1” may change depending on where you put the upload control.

HTH

  • You must to post comments
0
0

Perfect! Thank you again for you help!

  • You must to post comments
0
0

First: I managed to resolve with “independent” buttons. Meaning the standalone ones (I needed some time for me to understannd the concept).

 

Questions:

1. please give me a sample how to put this.getParent().u.upload() on ClientEvent, for execute, in code.

 

2. I have a DatagridView with a column template DataGridViewButtonCell. On code, it’s like:

var lc = new DataGridViewButtonColumn();

lc.CellTemplate = new DataGridViewButtonCell();

lc.DataPropertyName = dt.Columns[i].ColumnName;

lc.Name = dt.Columns[i].ColumnName;

lc.CellTemplate.Style.ForeColor = System.Drawing.Color.Navy;

dg.Columns.Add(lc);

 

When user click on cell, I have code on CellMouseClick event, and I want to initiate a file upload. Please give me a solution on how to accomplish that.

Or a way to initiate a file upload when click a cell, on a specific column.

Thank you for very quick reaction!

  • You must to post comments
0
0

You cannot call u.UploadFiles() in Firefox, it will block the event. You need to call the event on the client side.

You can set all the properties in the designer. The only property that must be set in OnLoad is upload.Visible = true otherwise the client widget is not created for invisible controls until they are made visible once or used in a client call. If you send a small test case I can fix it for you.

You can attach client events to the dynamically created buttons using button1.ClientEvents.Add(…) or button1.AddClientEventListener()

https://wisej.com/docs/2.1/html/P_Wisej_Web_Control_ClientEvents.htm

https://wisej.com/docs/2.1/html/M_Wisej_Web_Control_AddClientEventListener.htm

 

 

  • You must to post comments
0
0

I did what you told me, but I encounter 2 problems:

First one:

  1. I put an upload control on form (named u),
  2. in Load event of the form I put:
    u.Uploaded += U_Uploaded;
    u.AllowMultipleFiles = false;
    u.AllowedFileTypes = “.pdf”;
    u.UploadFiles(); //without that on the first click it doesn’t fire ?!?!
  3. On the Button click event I put u.UploadFiles();

Without the u.UploadFiles(); called without effect on form.Load, at the first push of the button nothing happens. On the secont, third, etc it works. It’s a bug?

edit: step 3 this is not necessary; it’s stupid me! On button.Click no code is necessary, the javascript fires u.UploadFiles(); Still, withou calling u.UploadFiles(); on form.Load it’s not working.

Second problem (and that’s the big one):

I have tables (datagridview) with (some) columns as buttons (DataGridViewButtonCell). Some of them must upload files. I’m not sure how can I use that mechanism with dinamically created buttons? I mean the the event triggered is CellMouseClick. How can I  attach a client side event to the button by code?

Thank you,

Adrian

  • You must to post comments
0
0

You can also use the upload control directly and make it look like a button easily:

Set upload1.ShowValue = false.

If you want to change the colors or the icon you can.

If you want to use the same theme as a regular button set the AppearanceKey property to “button”.

  • You must to post comments
0
0

The upload works well in all browsers. It’s the server-side triggering that is blocked by some browsers and some versions of the the browser because they don’t allow certain actions to be started without a user interaction  (a click). The way to make  it work is to attache a client side event to the button like the attached screenshot.

Also in your code you are creating a new upload control on each click, it will create a new <input> in the browser each time. You should create the upload control once. Drop it on the page and make it not visible on OnLoad().

Attachment
  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.