Rad upload is not working in Rad Window

Thread is closed for posting
6 posts, 0 answers
  1. Prassin
    Prassin avatar
    87 posts
    Member since:
    Jun 2012

    Posted 17 Jul 2012 Link to this post

    Hi All,

    Rad upload is not working on my Rad window.. please have look below code and fix the error.

    Aspx:
    <telerik:RadWindow runat="server" ID="RadWindow_ContentTemplate" RestrictionZoneID="ContentTemplateZone"
             Modal="true" Skin="Office2010Blue" Height="350px" Width="478px">
             <ContentTemplate>
                 <p class="contText">
                     Hi, Pleae upload photo here and click complete button..
                 </p>
                 <div class="contButton">
                     Upload photo :
                     <telerik:RadUpload ID="imgUpload" runat="server" ToolTip="File Size limit 500KB, (jpg, bmp, png, gif)"
                         ControlObjectsVisibility="None" Width="178px" TargetFolder="~/Upload/" OnClientFileSelected="OnClientFileSelectedHandler">
                     </telerik:RadUpload>
                 </div>
                 <div class="contButton">
                     <asp:Image ID="imgLogo" runat="server" Visible="true" AutoAdjustImageControlSize="false"
                         Height="123px" Width="130px"></asp:Image></div>
                 <div class="contButton">
                     <telerik:RadButton ID="RadButtonUpload" runat="server" Text="Complete" Width="200px">
                         <Icon SecondaryIconCssClass="rbOpen" SecondaryIconRight="4" SecondaryIconTop="4" />
                     </telerik:RadButton>
                 </div>
                 <div class="contButton">
                     <telerik:RadTextBox ID="RadButton1" runat="server" Text="Upload" Width="200px" Visible="False">
                     </telerik:RadTextBox>
                 </div>
             </ContentTemplate>
         </telerik:RadWindow>

    Script:
    <script type="text/jscript">
               function OnClientFileSelectedHandler(sender, eventArgs) {
                   var img = document.getElementById("<%= imgLogo.ClientID %>");
                   img.src = eventArgs.get_fileInputField().value;
               }
           </script>

    please clarify the error.

    Regards,

    Prassin
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 17 Jul 2012 Link to this post

    Hello,

    I was able to make the RadUpload working by changing the  script type as text/javascript.
    JS:
    <script type="text/javascript">
         function OnClientFileSelected(sender, eventArgs)
         {
             var img = document.getElementById("<%= imgLogo.ClientID %>");
            img.src = eventArgs.get_fileInputField().value;
         }
    </script>
    Hope this helps.

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Prassin
    Prassin avatar
    87 posts
    Member since:
    Jun 2012

    Posted 17 Jul 2012 Link to this post

    Hi Shinu,

    Thanks for your replay..
    I have changed the script like your script...
    <script type="text/javascript">
               function OnClientFileSelectedHandler(sender, eventArgs) {
                   var img = document.getElementById("<%= imgLogo.ClientID %>");
                   img.src = eventArgs.get_fileInputField().value;
               }
           </script>

    but still i cant fill the image here....

    Please confirm me the error of this script..

    Regards,

    Prassin
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Jul 2012 Link to this post

    Hello,

    The following code will work correctly on IE browser only, since in Firefox the input.value returns the filename instead of the full path to the file.

    For security reasons the above code will work only on localhost, to make it work remotely you need to add the site to the Trusted Sites.Check the following help documentation which explains the same.
    How to Preview Image Before Upload (IE only)

    Thanks,
    Shinu.

  6. Prassin
    Prassin avatar
    87 posts
    Member since:
    Jun 2012

    Posted 18 Jul 2012 Link to this post

    HI Shinu,

    Thanks for your replay..

    if it is not compatible for all browsers then is there any way to show that Rad upload and asp image  inside the rad grid fromtemplate..
    my requirement is  when i select the file path that time the respective image need to be shown..
    my rad grid having add,edit,delete functionality.. is there any solution with this then please share with me..

    Regards,

    Prassin 
  7. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 18 Jul 2012 Link to this post

    Hello Prassin,

     
    When using RadUpload such behavior is highly restricted for security reasons as it is explained in the article that was linked by Shinu so you can consider using RadAsyncUpload as it is shown in this on-line demo.

    Hope this will be helpful.

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017