如何在单击Button1时限制RadAsyncUpload上载文件

时间:2015-09-12 06:10:58

标签: c# asp.net vb.net visual-studio telerik

我的网页上有RadAsyncUpload和两个按钮。 Button1和Button2

问题是RadAsyncUpload是按钮点击上传文件我希望它只是在Button1上传文件点击,

以下是设计代码

<div>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
    </div>
    &nbsp;<telerik:RadAjaxLoadingPanel 
        ID="RadAjaxLoadingPanel1" Runat="server" MinDisplayTime="2000" Skin="Default">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    </telerik:RadAjaxManager>
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" height="200px" 
        HorizontalAlign="NotSet" LoadingPanelID="RadAjaxLoadingPanel1" width="300px">
        <telerik:RadAsyncUpload ID="RadAsyncUpload1" runat="server" 
            MultipleFileSelection="Automatic" 
    UploadedFilesRendering="BelowFileInput">
        </telerik:RadAsyncUpload>
        <asp:Button ID="Button1" runat="server" Text="Button1" />
        &nbsp;<asp:Button ID="Button2" runat="server" Text="Button" />
    </telerik:RadAjaxPanel>

和我的VB.NET代码:

Imports Telerik.Web.UI
Imports System.IO
Partial Class Default2
    Inherits System.Web.UI.Page

    Protected Sub RadAsyncUpload1_FileUploaded(ByVal sender As Object, ByVal e As Telerik.Web.UI.FileUploadedEventArgs) Handles RadAsyncUpload1.FileUploaded
        Const relativePath As String = "~/Uploads/"
        Dim filename = e.File.FileName
        'Dim parentID = Convert.ToInt32(GridView1.SelectedValue)
        Dim filesize = Convert.ToInt32(e.File.ContentLength)
        Dim physicalSavePath = MapPath(relativePath) + filename

        'Store file info in database
        'Dim app_FilesAdapter = New app_FilesTableAdapter()
        'app_FilesAdapter.Insert(filename, relativePath & Convert.ToString(filename), parentID, 1, DateTime.Now, filesize)

        'Save physical file on disk
        e.File.SaveAs(physicalSavePath, True)
    End Sub

End Class

1 个答案:

答案 0 :(得分:2)

只需使用PostbackTriggers =&#34; Button1&#34; RadAsyncUpload的属性

谢谢!