Add Publish Confirm message

Vote:
 

Hi,

I would like to add a javascript 'are you sure you want to publish' confirmation popup for every time someone wants to publish any page in edit mode. Any help on how to do this would be greatly appreciated it.

Thank you

#44820
Oct 15, 2010 18:09
Vote:
 

You'd probably have to replace the standard aspx /ascx:es used by the edit interface. Start by finding the page or control which is holding the button / buttons you want to attach your event to. It's one of the files in the EPiServer install directory (usually placed in Program Files, check your virtual path mappings in web.config/episerver.config to see exactly where). Copy the file to your project.

Hopefully you can just add your javascript event to the button by adding some javascript code to your modified aspx/ascx. In some cases it might take manipulation of the codebehind. Use reflector to look at the class which the aspx/ascx inherits from. If you need to, you can get into the chain of inheritance by letting a class (codebehind) inherit from the class the original aspx/ascs inherits from, and let your new aspx/ascx inherit from this class.

Then look in episerver.config / web.config for the VirtualPathMappedProvider. That is included in the default config files but commented out. Activate it, and use the path mappings section to redirect the virtual path of the original aspx/ascx to your modified version.

#44824
Oct 16, 2010 9:31
Vote:
 

You could write a EditPanelPlugIn that FindControl's the Save&Publish-button and injects the confirm()-script to it.

/johan

#44828
Oct 16, 2010 22:53
Vote:
 

If you take a look at

http://www.slideshare.net/EPiServerMeetupOslo/episerver-behind-the-scene

page 25, there is a method here you could use

#44839
Oct 18, 2010 12:26
Vote:
 

Hi Magnus, Johan and Anders.

Thank you very much for your help. I managed to get it working using the following code in an EditPanel Plugin:

EditPanel editPanel;
PropertyDataForm dataform;

public PlugInDescriptor[] List()
{
   editPanel = HttpContext.Current.Handler as EditPanel;
   if(editPanel != null)
       editPanel.PreRender += new EventHandler(editPanel_PreRender);

   return new PlugInDescriptor[] {};

}

 

 

 

public void editPanel_PreRender(object sender, Eventargs e)
{
  dataForm = FindControl<PropertyDataForm>((Control)sender, null)

  ToolButton SaveAndPublishButton = FindControl<ToolButton>(dataForm.Parent, "SaveAndPublish");
  EPiServer.ClientScript.ScriptManager.Current.AddEventListener(SaveAndPublishButton, new ConfirmEvent(EventType.Click, "Are you sure you want to publish?"));

}

public T FinControl<T>(Control control, string id) where T : Control
{
   T ctrl = control as T;
   if(ctrl != null && (id == null || id.Equals(ctrl.ID)))
      return ctrl;

   foreach(Control c in control.Controls)
   {
      ctrl = FindControl<T>(c, id);
      if(ctrl = null)
         return ctrl.
   }
   return null;
}

Thank you guys once again.

#44841
Oct 18, 2010 13:50
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.