Modify RootFolder and refresh using Callback, not Postback
Question asked by David Arnold - 1/25/2016 at 12:49 PM
Using FileUltimate in an Update Panel (or a Callback Panel using DevExpress) seems to cause issues, namely the control appears to be blank.  
I'm basically looking for a way to reset the Root Folder(s) using only a Callback and then make a call for FileUltimate to refresh.
Is it even possible to modify the RootFolders using a callback instead of a Postback?  If so, is there a client side method I can call once the callback is complete?

4 Replies

Reply to Thread
Cem Alacayir Replied
Employee Post Marked As Answer
FileUltimate is a complex control so it will not work in UpdatePanel. Yes it's possible to update root folders on the client side however the control state needs to be updated on the server too because client side never knows the actual physical locations for security purpose.
So it's pretty complex, I think you should better use a iframe solution or you should accept the whole page postback.
For reference, I tried to prepare you an example project with some workarounds but I hit some problems with ScriptManager it seems some default ASP.NET javascript is conflicting, in browser console "TypeError: a is null" error is logged. Do you see a similar error? Because this error will also cause the control to appear blank. (UPDATE: This turned out to be a bug which is now fixed with release
Even I couldn't get it to work for now, here is the idea:
<asp:UpdatePanel runat="server">
		<asp:HiddenField ID="StateId" runat="server" /><br />
		<asp:HiddenField ID="UpdatedRootFolders" runat="server" /><br />
		<asp:Button ID="Button1" runat="server" Text="Update RootFolders" OnClick="Button1_Click" />                

<GleamTech:FileManager ID="fileManager" runat="server" Width="800" Height="600"/>
and in codebehind:
protected void Page_Load(object sender, EventArgs e)
	StateId.Value = fileManager.StateId;

protected void Button1_Click(object sender, EventArgs e)
	var state = ControlStateManager.GetState<FileManagerState>(StateId.Value);

	//Do your root folder modifications here
	state.RootFolders.Add(new FileManagerRootFolder { Name = "Test", Location = "/" });

	UpdatedRootFolders.Value = JsonConvert.SerializeObject(EnumerateRootFolders(state.RootFolders));

private IEnumerable<object[]> EnumerateRootFolders(FileManagerRootFolderCollection rootFolders)
	for (var i = 0; i < rootFolders.Count; i++)
		var folder = rootFolders[i].GetFolder(FileManagerAccessControl.Root);
		var expandable = folder.CheckPermissions(FileManagerPermissions.ListSubfolders);
		var hash = CryptoManager.Hash(rootFolders[i].Location.ToString());

		yield return new object[]
Then I was going to call a client-side method on fileManager instance to load new root folders which are serialized in UpdatedRootFolders hidden field.
Cem Alacayir Replied
Employee Post
Hi David,
It turns out that you may have hit a bug when you saw the control blank. When no root folders were defined, the control was not being rendered due to a JS error (blank page). This is now fixed with release, it's live on the site.
For example omitting a root folder definition (either in markup or codebehind) like this:
<GleamTech:FileManager ID="fileManager" runat="server" />
would cause the control to appear blank due to a JS error. Now the file manager is displayed correctly as expected (it seems this became broken in one of the recent releases).
Let me know if you need additional help on your UpdatePanel problem (maybe you decided to use iframe or full postback as I suggested?).
David Arnold Replied
Thanks, Cem!

I hope to start looking at the alternative methods tomorrow...iframe was one of my thoughts, as well.

I'll try the new control and let you know how it goes.
David Arnold Replied
I ended up using an iframe for now.  The only drawback is the total redraw of the component when needing to refresh the iframe.  I can also verify that using the 5.0.7 build without Root Folders set, I now can see the panel displayed (no longer blank).
So, for clarification, even if we were to perform a callback that did not include the FileManager component (e.g. FileManager is not in an Update Panel or Callback Panel), and (re)set the Root Folders in Page_Load, for example, there is no subsequent client-side call we could make after the callback completes to tell the FileManager control to refresh/rebuild of the just-modified data?  I realize FileManager is more of a Web API type approach (pure javascript client with backend HTTP handler) and does not directly participate in a lot of the ASP.NET page lifecycle, but just trying to make more sense of it from an understanding point of view (and to possibly eliminate the complete control rebuild).

Reply to Thread