简体   繁体   English

Asp.net-从头开始创建自定义文件上传控件

[英]Asp.net - Create a custom File Upload Control from scratch

I have tried using the FileUpload control in ASP.net and found some strange problems. 我尝试在ASP.net中使用FileUpload控件,但发现了一些奇怪的问题。 I have decided to scrap this control and create a custom control. 我决定取消此控件并创建一个自定义控件。 Is it possible to create a file upload control from scratch? 是否可以从头开始创建文件上传控件?

thanks 谢谢

AsyncFileUpload is an ASP.NET AJAX Control that allows you asynchronously upload files to server. AsyncFileUpload是一个ASP.NET AJAX控件,允许您异步将文件上传到服务器。 The file uploading results can be checked both in the server and client sides. 可以在服务器端和客户端中检查文件上传结果。 You can save the uploaded file by calling the SaveAs() method in a handler for the server UploadedComplete event. 您可以通过在服务器UploadedComplete事件的处理程序中调用SaveAs()方法来保存上载的文件。

Check out this: http://www.asp.net/ajax/ajaxcontroltoolkit/samples/AsyncFileUpload/AsyncFileUpload.aspx 看看这个: http : //www.asp.net/ajax/ajaxcontroltoolkit/samples/AsyncFileUpload/AsyncFileUpload.aspx

Yes, it's possible. 是的,有可能。 Essentially your control will just have to render an input tag with a type of file, eg: 本质上,您的控件将只需要使用一种文件类型来呈现input标签,例如:

protected override void Render(HtmlTextWriter output)
{       
   output.Write("<input type='file' />");   
}

However, this is a gross simplification of the problem...! 但是,这是问题的严重简化……!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM