如何扩展AsyncFileUpload类?

时间:2013-04-08 16:51:10

标签: c# asp.net asp.net-mvc asp.net-mvc-3 c#-4.0

我正在尝试扩展AsyncFileUploadEventArgs类。下面是我的代码

public class abc : AsyncFileUploadEventArgs
{
    public abc() { }
    public int MyProperty { get; set; }

    public String FileName { get { return fileName; } }
    private string fileName;

    public string FileSize { get { return fileSize; } }
    private string fileSize;

    public AsyncFileUploadState State { get { return State; } }
    private AsyncFileUploadState state;

    public string StatusMessage { get { return statusMessage; } }
    private string statusMessage;

    public abc(AsyncFileUploadState state, string statusMessage, string filename, 
                                                                   string filesize)
    {
        this.fileName = filename;
        this.state = state;
        this.statusMessage = statusMessage;
        this.fileSize = filesize;
    }
}

AsyncFileUploadEventArgs类的元数据

public class AsyncFileUploadEventArgs : EventArgs
{
    public AsyncFileUploadEventArgs();
    public AsyncFileUploadEventArgs(AsyncFileUploadState state, string statusMessage, string filename, string filesize);

    public string FileName { get; }
    public string FileSize { get; }
    public AsyncFileUploadState State { get; }
    public string StatusMessage { get; }
}

以下是AsyncFileUpload UploadedComplete处理程序

protected void AsyncFileUpload1_UploadedComplete(object sender, abc e)
{
}

以下是AsyncFileUpload的用户控件

<cc1:AsyncFileUpload ID="AsyncFileUpload1" Width="400px" 
    runat="server" OnUploadedComplete="AsyncFileUpload1_UploadedComplete" />

我的动机是 - 我正在尝试验证AsyncFileUpload1_UploadedComplete处理程序中所选文件的高度和宽度。我正在服务器端,因为AsyncFileUploadEventArgs类中没有高度和宽度。

所以,我正在考虑添加名为Height的新属性并为其分配值服务器端并访问它的客户端。

通过扩展课程,它给了我以下错误

  

'AsyncFileUpload1_UploadedComplete'没有重载与委托相匹配   'System.EventHandler'

你能说出原因吗?

1 个答案:

答案 0 :(得分:-2)

应该为UploadedComplete事件使用此参数:

protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)