This is a migrated thread and some comments may be shown as answers.

Panel not working

4 Answers 49 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Web Services
Top achievements
Rank 2
Web Services asked on 02 Nov 2010, 05:25 PM
I'm sure this is simple but I'm missing something and I can't figure out what. I'm just trying to get my function to respond when I click on a button within a ajax panel. Here is my aspx.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="admin_Default" %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
         
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1" HorizontalAlign="NotSet">
             
            Please select a file:
            <asp:FileUpload ID="FileUpload1" runat="server" /><br />
             
            <asp:Button ID="upload" Text="Upload" runat="server" /><br />
            <asp:Label ID="output" runat="server"></asp:Label>
             
    </telerik:RadAjaxPanel>
 
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="75px" Transparency="10" BackgroundPosition="Center">
        <img alt="Loading..." src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.LoadingProgressBar.gif") %>'
            style="border: 0px;" />
        </telerik:RadAjaxLoadingPanel>
    </div>
    </form>
</body>
</html>


And here is my vb. What am I missing
Partial Class admin_Default
    Inherits System.Web.UI.Page
 
    Protected Sub upload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles upload.Click
        Response.Write("test")
 
        If (FileUpload1.HasFile) Then
 
            Try
                Dim name As String = FileUpload1.FileName.ToString
                Dim ext As String = System.IO.Path.GetExtension(FileUpload1.FileName)
 
                If (ext = ".csv") Then
 
                    FileUpload1.SaveAs(Server.MapPath("~/admin/temp/" & name))
 
                Else
 
                    output.Text = "<span style='color: red;'>Invalid file type. File must be CSV.</span>"
 
                End If 'if ext = .csv
 
 
            Catch ex As Exception
                Response.Write(ex.ToString)
            End Try 'fileupload.hasfile
 
        Else
 
            output.Text = ("<span style='color: red;'>Please make sure you have selected a file and the size is greater than 0 bytes.</span>")
 
        End If 'fileupload.hasfile
 
    End Sub
End Class

4 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 03 Nov 2010, 01:09 PM
You can ajaxify a file upload. If you want to upload a file, you need to cancel the ajax request when the upload button is pressed. Like in this help article:

http://www.telerik.com/help/aspnet-ajax/ajxajaxandupload.html

I hope that helps.
0
Sebastian
Telerik team
answered on 03 Nov 2010, 01:12 PM
Hi guys,

An alternative solution would be to use RadAsyncUpload to upload files asynchronously. Consider it as another option to get what you want.

Best,
Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Web Services
Top achievements
Rank 2
answered on 03 Nov 2010, 02:36 PM
Forgive my ignorance, but what is the benefit of using the async upload over just a normal file uploader?
0
Sebastian
Telerik team
answered on 03 Nov 2010, 02:38 PM
Hello Web Services,

The major advantage is that you will upload files asynchronously instead of using plain postbacks. Examine the online demos to see that in action.

Best regards,
Sebastian
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Ajax
Asked by
Web Services
Top achievements
Rank 2
Answers by
Cori
Top achievements
Rank 2
Sebastian
Telerik team
Web Services
Top achievements
Rank 2
Share this question
or