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”;
private void U_Uploaded(object sender, UploadedEventArgs e)
string nf = …;
First: I managed to resolve with “independent” buttons. Meaning the standalone ones (I needed some time for me to understannd the concept).
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;
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 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()
I did what you told me, but I encounter 2 problems:
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?
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?
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”.
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().
Please login first to submit.