我喜欢 skydrive 文件上传控件的拖放功能。我如何着手开发类似的控件?
问问题
940 次
3 回答
0
检查我的源代码是否有用
using System;
using System.Data.ProviderBase;
using System.Text;
using System.Xml.Schema;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.Globalization;
using System.Diagnostics;
using System.ComponentModel.Design;
using System.Data.Common;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Collections;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void upload_Click(object sender, EventArgs e)
{
if (fileupload.HasFile)
try {
fileupload.SaveAs("C:\\Uploads\\" + fileupload.FileName);
lbl.Text = "File name: " +
fileupload.PostedFile.FileName + "<br>" +
fileupload.PostedFile.ContentLength + " kb<br>" +
"Content type: " +
fileupload.PostedFile.ContentType;
}
catch (Exception ex) {
lbl.Text = "ERROR: " + ex.Message.ToString();
}
else
{
lbl.Text = "You have not specified a file.";
}
}
}
HTML:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="fileupload.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="myForm" runat="server">
<asp:FileUpload ID="fileupload" runat="server" />
<asp:Button ID="upload" Text="Upload" runat="server" onclick="upload_Click" />
<asp:Label ID="lbl" runat="server"></asp:Label>
</form>
</body>
</html>
于 2009-09-13T11:19:54.730 回答
0
这是我找到的 SilverLight 解决方案:
http://www.silverlightshow.net/items/SL4-Desktop-Drag-and-Drop-Silver-Sky.aspx
于 2012-04-14T15:43:20.563 回答