Hello,
I have a usercontrol that provides an Event:
public event EventHandler<FilePickerSelectionEventArgs> FileSelectionChanged;
This event is raised by the control using:
protected void RaiseFilePickerSelectionChangedEvent(ArrayList selectedFiles)
{
// Copy handler to temp var to make operation thread safe:
EventHandler<FilePickerSelectionEventArgs> handler = FileSelectionChanged;
if (FileSelectionChanged!=null)
{
FilePickerSelectionEventArgs args = new FilePickerSelectionEventArgs();
args.SelectedFiles = selectedFiles;
handler(this, args);
}
}
This usercontrol is placed inside an aspx page without masterpage. I need to update other controls that exist on the page when the UC event is raised. So, in the page I placed the code:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="filePicker" EventName="FileSelectionChanged">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="labelStatus" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<UC:FilePicker id="filePicker" runat="server" AllowedFileExtensions="jpg,jpeg,png" OnFileSelectionChanged="filePicker_FileSelectionChanged"></UC:FilePicker>
The problem is that RadAjaxManager is not working with this event. I'm sure it's correct because if I change it to something that does not exist, an error is returned saying that no event with that name is found.
Tried doing AjaxSettings in my page code behind but that did not work as well.
Tried to use a simple UpdatePanel:
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="labelStatus" runat="server"></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="filePicker" EventName="FileSelectionChanged" />
</Triggers>
</asp:UpdatePanel>
Hi Hugo,
My first assumption is that the FilePicker is not making any PostBacks. I am curious though, how does the FilePicker make a PostBack, what makes it trigger the "FileSelectionChanged" event?
Can you show us the code you have inside the FilePicker (ASCX and ASCX.CS) files?
Hello,
The event is triggered when the user presses a button to submit the selected files. Inside the Click event of that button, the method RaiseFilePickerSelectionChangedEvent is called. Very simple.
I'm sure there's a postback because I also have an hidden input field that gets the ID of the selected files when that button is pressed. Also, the only difference in code are the lines for Radajax setting or the code for UpdatePanel. When using yours it does not work, and when using UpdatePanel it works.
Found the following in the documentation:
https://docs.telerik.com/devtools/aspnet-ajax/controls/ajaxpanel/troubleshooting/common-issues
Problem: Setting the EventName property in the AJAX settings for the AJAX initiator control does not work.Solution: The EventName property is obsolete for RadAjax . If your logic strongly relies on it, you should use an asp:UpdatePanel toAJAX-enable the controls instead of RadAjax . Another option is to wrap the updated control in a RadAjaxPanel instead of using the RadAjaxManager to AJAX-enable it.
I don't quite understand what you mean with the eventName being obsolete because I don't know how it could be done differently.