Custom Control with a "Choose Avatar" control

Posted by Community Admin on 03-Aug-2018 13:06

Custom Control with a "Choose Avatar" control

All Replies

Posted by Community Admin on 19-Oct-2010 00:00

Greetings,


I have a Custom Control where I'm trying to create one of those "Choose Avatar" controls, basically by doing the same that's shown on your example, located at http://demos.telerik.com/aspnet-ajax/upload/examples/async/ajaxprocessing/defaultcs.aspx.

If I create a page on the root of my Sitefinity website and use the code available on that example everything works fine, however if I attempt to use it while inside a Custom Control then the Thumbnail ain't updated. The Ajax is called and the FileUpload method of the RadAsyncUpload is also called and the property DataValue of the Thumbnail seems to be updated together with the ImageUrl which points to telerik's handler, however no picture is displayed.

Below is the current code that I have:

TestWidget.cs
protected override void InitializeControls(GenericContainer controlContainer)
        
            AsyncUpload1.FileUploaded += new FileUploadedEventHandler(AsyncUpload1_FileUploaded);
        
 
        protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
        
            Thumbnail.Width = Unit.Pixel(200);
            Thumbnail.Height = Unit.Pixel(150);
 
 
 
            using (Stream stream = e.File.InputStream)
            
                byte[] imageData = new byte[stream.Length];
                stream.Read(imageData, 0, (int)stream.Length);
                Thumbnail.DataValue = imageData;
            
 
 
        
 
        protected virtual RadAsyncUpload AsyncUpload1
        
            get return base.Container.GetControl<RadAsyncUpload>("AsyncUpload1", true);
        
 
        protected virtual RadBinaryImage Thumbnail
        
            get return base.Container.GetControl<RadBinaryImage>("Thumbnail", true);
        

TestWidget.ascx
<%@ Control Language="C#"%>
 
<%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sitefinity" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" %>
 
<sitefinity:ResourceLinks ID="resourcesLinks" runat="server" UseEmbeddedThemes="True">
    <sitefinity:ResourceFile AssemblyInfo="Website.Widgets.TestWidget.TestWidget, Website.Widgets" Name="Website.Widgets.TestWidget.Resources.TestWidget.css" Static="true"/>
</sitefinity:ResourceLinks>
 
 
    <telerik:RadAjaxManager ID="RadAjaxManagerTest" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadAjaxManagerTest">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="Thumbnail" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
 
    <script type="text/javascript">
        function fileUploaded(sender, args)
            $find('<%= RadAjaxManagerTest.ClientID %>').ajaxRequest();
            sender.deleteFileInputAt(0);
        
    </script>
 
    <div class="upload-panel">
        <%-- For the purpose of this demo the files are discarded.
             In order to store the uploaded files permanently set the TargetFolder property to a valid location. --%>
        <telerik:RadBinaryImage runat="server" Width="200px" Height="150px" ResizeMode="Fit"
            ID="Thumbnail" ImageUrl="blank.png" AlternateText="Thumbnail" />
        <telerik:RadAsyncUpload runat="server" ID="AsyncUpload1" MaxFileInputsCount="1" OnClientFileUploaded="fileUploaded"
            >
            <Localization Select="Choose Avatar" />
        </telerik:RadAsyncUpload>
    </div>

Is this a known bug? And if so, is there a solution for this already?

Thanks in advance,
Daniel

Posted by Community Admin on 02-Nov-2010 00:00

Hi Daniel,

There is a problem with RadAjaxManager, which is null when you make the asynchronous call. We are working on this issue. Unfortunately I am not able to send you a fix, because the issue is not something trivial.

Kind regards,
Ivan Dimitrov
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

Posted by Community Admin on 18-Mar-2011 00:00

Is the AjaxManager still having issues since this post?

Posted by Community Admin on 24-Mar-2011 00:00

Hello Kristian,

We will introduce a fix for this with our Q1 release that is around the corner. We have adopted the virtual path provider and have made our own parse obsolete so that there are no issues with the ajax manager. Furthermore we will be delivering User Profiles which feature the avatar functionality.

Thank you for contacting us.

Regards,
Hristo Borisov
the Telerik team

This thread is closed