I have an aspx page and a code behind. The content of the page is dynamically created via XML and XSLT tContent.Controls.Add(master.ParseControl(ApplyXslt(xml, xsl_trans, xsl_args)));
. Where tcontrol
is the control <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
. In the XSLT I have a telerik control
<telerik:RadAsyncUpload RenderMode="Lightweight" ID="AsyncUpload1" runat="server"
OnClientFilesUploaded="OnClientFilesUploaded" OnFileUploaded="AsyncUpload1_FileUploaded"
MaxFileSize="2097152" AllowedFileExtensions="jpg,png,gif,bmp"
AutoAddFileInputs="false" Localization-Select="Upload Image" />
<asp:Label ID="Label1" Text="*Size limit: 2MB" runat="server" Style="font-size: 10px;"></asp:Label>
the control has an event called onFileUploaded
and I have it set like this OnFileUploaded="AsyncUpload1_FileUploaded"
. In my Code behind I have a function defined like this
protected void AsyncUpload1_FileUploaded(object sender, FileUploadedEventArgs e)
{
string newfilename = "logo." + e.File.GetExtension();
string path = "/customer/" + MiscFunctions.currentCustXml+"/"+ newfilename;
e.File.SaveAs(path);
}
I know that the onFileUploaded
event is fired on post back. But for some reason it is not being called. But when I cut and paste the control directly into the content of <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
, the eventhandler gets fired correctly. At first I thought it was becuase the generated content was being added after the controls are initialize, the genreated content was added when Page_Load
was called, thus the telerik control is not initialize correctly. So I then move the code to Page_Preinit
and the event is still not being called. Is there something I am missing? Or is what I am doing not possible as controls are initialize before the page life cycle?