Radupload dont move

Thread is closed for posting
2 posts, 0 answers
  1. Fabio Cirillo
    Fabio Cirillo avatar
    180 posts
    Member since:
    Jan 2010

    Posted 06 Dec 2012 Link to this post

    Why when I start the transfer from the site of a file on the remote server appears radloadingpanel but does not move?

    this my code into vbnet and asp:

    Imports System
    Imports System.Collections
    Imports System.ComponentModel
    Imports System.Data
    Imports System.Drawing
    Imports System.IO
    Imports System.Web
    Imports System.Web.SessionState
    Imports System.Web.UI
    Imports System.Web.UI.WebControls
    Imports System.Web.UI.HtmlControls
    Imports Telerik.Web.UI
    Imports System.Data.SqlClient
    Imports Telerik.Web.UI.Upload
     
    Public Class UploadImgProfile
        Inherits RadAjaxPage
        Public _image As String
    #Region "routine"
        Private Sub update_image(ByVal idutente As Int32, ByVal image As String)
            Try
                Dim conString = ConfigurationManager.ConnectionStrings("TrycontactString")
                Dim strConnString As String = conString.ConnectionString
                Using db As New SqlConnection(strConnString)
                    db.Open()
                    Using sqlcmd As New SqlCommand("Sp_update_imageprofile", db)
                        sqlcmd.CommandType = CommandType.StoredProcedure
                        sqlcmd.Parameters.AddWithValue("@id", SqlDbType.Int).Value = idutente
                        sqlcmd.Parameters.AddWithValue("@imageprofile", SqlDbType.VarChar).Value = image
                        sqlcmd.ExecuteNonQuery()
                    End Using
                End Using
            Catch ex As SqlException
                Exit Sub
            Catch ex As Exception
                Exit Sub
            End Try
        End Sub
    #End Region
            Protected Sub Imgbtnesci_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles Imgbtnesci.Click
            ClientScript.RegisterStartupScript(Me.GetType, "closeWindow", "<script type='text/javascript'>GetRadWindow().close('" & ViewState("DirImage") & "')</script>")
        End Sub
     
        Protected Sub CustomValidator1_ServerValidate(source As Object, e As System.Web.UI.WebControls.ServerValidateEventArgs) Handles CustomValidator1.ServerValidate
            e.IsValid = (RadUpload1.InvalidFiles.Count = 0)
        End Sub
     
        Protected Sub Imgbtnupload_Click(sender As Object, e As System.EventArgs) Handles Imgbtnupload.Click
            If RadUpload1.UploadedFiles.Count > 0 Then
                ViewState("DirImage") = "/image/image_utenti/" & RadUpload1.UploadedFiles.Item(0).FileName
                update_image(Session.Item("idutente"), ViewState("DirImage"))
                Label1.Text = "File caricato: " & RadUpload1.UploadedFiles.Item(0).FileName & "(" & RadUpload1.UploadedFiles.Item(0).ContentLength & " " & "bytes)"
                  Else
                Label1.Visible = True
            End If
        End Sub

    <form id="form1" runat="server">
    <telerik:RadAjaxManager runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="Imgbtnupload">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="form1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <div style="font-family: Verdana; font-size: small; background-image: url('Image/Upload.jpg'); background-repeat: no-repeat; width: 350px; height: 230px">
         <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server"
             Skin="Simple" HorizontalAlign="Center" Width="350px" BorderColor="#D5842B"
             BorderStyle="Double" BorderWidth="1px">
         </telerik:RadAjaxLoadingPanel>
         <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
        </telerik:RadScriptManager>
        <div>
             <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" height="230px"
             width="300px" HorizontalAlign="NotSet"
                ClientEvents-OnRequestStart="conditionalPostback">
                 <table style="border: 0px; margin: 0px; padding: 0px; width: 350px;">
                     <tr>
                         <td style="border-style: none; border-color: inherit; border-width: 0px; margin: 0px; padding: 0px; text-align: center; ">
                              </td>
                     </tr>
                     <tr>
                         <td style="border-style: none; border-color: inherit; border-width: 0px; margin: 0px; padding: 0px; text-align: center; height:23px">
                              </td>
                     </tr>
                     <tr>
                         <td style="border-style: none; border-color: inherit; border-width: 0px; margin: 0px; padding: 0px; text-align: center; height:23px">
                             <asp:Label ID="Label1" runat="server" Text="Nessun file caricato"
                        ForeColor="Green"></asp:Label>
                         </td>
                     </tr>
                     <tr>
                         <td style="border-style: none; border-color: inherit; border-width: 0px; margin: 0px; padding: 0px; text-align: left; vertical-align: top; height: 50px">
                             <telerik:RadUpload ID="RadUpload1" Runat="server"
                        AllowedFileExtensions="jpg,jpeg,png,gif" OverwriteExistingFiles="True"
                        TargetFolder="public/image_profile" ControlObjectsVisibility="None"
                        InputSize="40" Height="22px" style="text-align: left" Skin="Sunset"
                             Width="343px">
                                 <Localization Select="Cerca" />
                             </telerik:RadUpload>
                             <div style="font-size:x-small">
                                      
                                 <div style="text-align:center">
                                     <asp:Label ID="Label2" runat="server"
                                         Text="Il file deve avere le seguenti estensioni: .jpg, .jpeg, .png"></asp:Label>
                                     <br />
                                     <asp:Label ID="Label3" runat="server"
                                          
                                         Text="Per avere un'ottima risoluzione si consigliano queste dimenrsioni: 128x127 pixel"></asp:Label>
                                     <br />
                                     <asp:CustomValidator ID="CustomValidator1" runat="server"
                                         ClientValidationFunction="validateRadUpload"
                                         ErrorMessage="File errato o non selezionato" Font-Bold="True" ForeColor="Red"
                                         OnServerValidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
                                 </div>
                             </div>
                             <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
                                 <script type="text/javascript">
                                         function conditionalPostback(sender, args) {
                                             if(args.get_eventTarget() == "<%= imgbtnupload.UniqueID %>") {
                                                 args.set_enableAjax(false);
                                             //var panel = $find("<%= RadAjaxLoadingPanel1.ClientID %>");
                                             //var divElementStyle = panel.get_element().style;
                                             //divElementStyle.position = 'absolute';
                                             //divElementStyle.left = args.get_eventTargetElement().offsetLeft + args.get_eventTargetElement().offsetWidth + "px";
                                             //divElementStyle.top = args.get_eventTargetElement().offsetTop + "px";
                                             //currentUpdatedControl = "<%= RadUpload1.ClientID %>";
                                             //panel.show(currentUpdatedControl);
                                             }
                                         }
     
                                         function validateRadUpload(source, e) {
                                             e.IsValid = false;
                                             var upload = $find("<%= RadUpload1.ClientID %>");
                                             var inputs = upload.getFileInputs();
                                             for (var i = 0; i < inputs.length; i++) {
                                                 //check for empty string or invalid extension    
                                                 if (inputs[i].value != "" && upload.isExtensionValid(inputs[i].value)) {
                                                     e.IsValid = true;
                                                     break;
                                                 }
                                             }
                                         }
                                         function GetRadWindow() {
                                             var oWindow = null;
                                             if (window.radWindow) oWindow = window.radWindow;
                                             else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
                                             return oWindow;
                                         }
                                     </script>
                             </telerik:RadCodeBlock>
                         </td>
                     </tr>
                     <tr>
                         <td style="border-style: none; border-color: inherit; border-width: 0px; margin: 0px; padding: 0px; text-align: center; height:10px">
                              </td>
                     </tr>
                     <tr>
                         <td style="border-style: none; border-color: inherit; border-width: 0px; margin: 0px; padding: 0px; text-align: center; height:10px">
                             <telerik:RadButton ID="Imgbtnupload" runat="server" Skin="Sunset"
                                 Text="Carica immagine" Width="120px">
                             </telerik:RadButton>
                         </td>
                     </tr>
                 </table>
         </telerik:RadAjaxPanel>
                         <div style="width: 344px; text-align:center">                            
                             <asp:ImageButton ID="Imgbtnesci" runat="server" ImageUrl="~/Image/esci1.png"
                                 ValidationGroup="esci" />
                         </div>
        </div
    </div>
    </form>
  2. Plamen
    Admin
    Plamen avatar
    2731 posts

    Posted 10 Dec 2012 Link to this post

    Hello,

     

    RadAsyncUpload itself is not preforming post back and if you want to use RadAjaxManager it you should either use AjaxRequest in this demo or submit the page with some button and ajaxify the button instead of RadAsyncUpoad.

    If you want an indicator while uploading you an use the Progress manager as it is done here.

    Kind regards,
    Plamen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top