Custom Control with a "Choose Avatar" control
Greetings,
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);
<%@ 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
>
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
Is the AjaxManager still having issues since this post?
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