November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
If I remember correctly there is no such event in EPiServer 5. I also checked the SDK for version 6, could't find it there either.
Thats correct. There exists now such event.
You can make you own by creating a page adaptor and attach yourself to the save button
Following up on Anders suggestion I found that you can use a control adapter on controlType EPiServer.UI.Hosting.VirtualPathControl
I'd originally had a page adapter on ~/secure/CMS/admin/FileManagement.aspx but that doesn't work when you want to catch the save from both the Admin and Edit modes.
Hi Deane,
Did you find a way to acheive this? I need to detect when the file summary has been edited.
Thanks,
Mark
I think we did the control adapter route. I'll check with the dev here that did it and we'll get you the code.
To do this we made a control adapter for the EPiServer.UI.Hosting.VirtualPathControl control. And then spun the collection of controls to find the save event, and added our own function to that save events click handler.
I've uploaded both the AdapterMapping and the Control adapter to : https://github.com/blendinteractive/EPiServer-Examples/tree/master/EditFileSummaryEvent
Just change SaveClicked to call whatever function you require. There is code to give you the current filename so you know which file is being edited.
There may be a more granular control to choose, but this worked fine for our needs. If you run into any issues let me know.
namespace Blend.PageAdapters
{
/// <summary>
/// This PageAdapter is being made to piggyback the EPiServer FileManagement page.
/// This specific adapter is looking for the Save button on the EditFileSummary
/// portion of the page.
/// </summary>
public class EditFileSummary : ControlAdapter
{
/// <summary>
/// Overloads the OnLoad event of the page this PageAdapter is piggybacking.
/// This allows us to add methods to the eventhandlers on the actual page.
/// </summary>
/// <param name="e">Event Args.</param>
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
var saveButton = FindControl<ToolButton>(Page, null);
if (saveButton == null)
{
return; // Error checking to make sure you bind to a TemplateButton
}
// Ensure we've bound to the save button
if (saveButton.Text == "Save" && saveButton.ToolTip == "Save")
{
saveButton.Click += this.SaveClicked; // Attach our method to the save button's Click event handler
}
}
/// <summary>
/// A simple generic way to find controls on the page.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="control">The parent control.</param>
/// <param name="id">The id of the control being looked for.</param>
/// <returns></returns>
private static T FindControl<T>(Control control, string id) where T : Control
{
T controlTest = control as T;
if (controlTest != null && (id == null || controlTest.ID.Equals(id)))
{
return controlTest;
}
foreach (Control c in control.Controls)
{
controlTest = FindControl<T>(c, id);
if (controlTest != null)
{
return controlTest;
}
}
return null;
}
/// <summary>
/// Displays every control on the page and its ID. Added for troubleshooting purposes in situations
/// where you are trying to find a control on the page and the source is not readily available. Call this function and
/// browse through the IDs then feed that ID into FindControl() to attempt to bind to it in this pageadapter.
/// </summary>
/// <param name="parent">Parent is the control whole children will be recursed.</param>
/// <param name="depth">Tracks how deep the function is for display purposes.</param>
private static void WriteControlValues(Control parent, int depth)
{
foreach (Control child in parent.Controls)
{
HttpContext.Current.Response.Write(new string('-', depth) + '>' + child + " - <b>" + child.ID + "</b><br />");
WriteControlValues(child, depth++);
}
}
/// <summary>
/// This function is the method we tie to the button click event on the save button.
/// </summary>
/// <param name="sender">The object which created the event.</param>
/// <param name="e">The arguements passed in the event.</param>
private void SaveClicked(object sender, EventArgs e)
{
var fileName = FindControl<HiddenField>(Page, "curFile");
var decoded = HttpContext.Current.Server.UrlDecode(fileName.Value);
if (String.IsNullOrEmpty(decoded))
{
return;
}
MetaIndexer.IndexFile(decoded);
}
}
}
Does anyone know of an event that can be hooked when the user edits a File Summary?
I know you can hook the addition or the change of a file. But if someone right-clicks on a file and selects "Edit File Summary," they are not affecting the underlying file, so no event applies.
I suspect there is no such event or way of hooking this moment, but before I go do anything drastic, I thought I'd check if anyone else knows of some way to gracefully handle this.