OpenFileDialog in ASP.NET

2019-08-31 00:42发布

问题:

How can I run sth like OpenFileDialog? In ASP.NET there's no this control.

Yes, there's option to use

<input type="file" name="filediag" />

but there's default name disabled to modifications.

I found either solution

<input type="file" name="filediag" style="display:none" />
<input type="button" value="browse..." onclick="document.form1.filediag.click()" />

but it doesn't work...or I'm doing sth wrong.

Is there other possibility to do this?

回答1:

You must have missed the FileUpload control - this is the equivalent to the HTML input type="file" used for uploading files.

It exposes the uploaded file - name and contents.