Try our conversational search powered by Generative AI!

Checking whether Save-button has been clicked

Vote:
 
Hi! I have a Web User Control in a template and wonder how I can check whether the "Save and preview"- or "Save and publish"-button has been clicked. I have tried to add a DataFactory.SavedPage-event to the Web User Control, but the event is called after the page-load event. If one of the save-buttons is clicked, some new content shall be generated and stored in one of the properties of the page, else the value shall be fetched direclty from this property. I do not manage to implement this functionality in a custom property since the property where I want to store the content is not available the first time I open the page in edit-mode. Best regards Bård Nymoen BEKK Consulting
#12150
Oct 15, 2004 16:42
Vote:
 
Have you tried the DataFactory's CreatingPage and SavingPage events? They occur just before the page is saved. CreatingPage occurs when a new page is about to get saved, SavingPage occurs when an existing page is about to get saved.
#13739
Oct 15, 2004 17:13
Vote:
 
Thanks for a quick and good answer. I have tried the SavingPage event, but I think these events are not exactly what I want....or I use them wrong :-) . In the page-load event, I want to read from a property and display the text in the HTML generated by the Web User Control. This is very common template-unit functionality. But when a user clicks the Save-button or Publish-button, I want to generate some new text to be stored in the property. Since the page-load is called before most other events, as CreatingPage, SavingPage etc., the new text will not be stored in the property before the property is read, but after. The ideally solution would be that I could do the check of the save-button in the page-load event. In this way it would be possible to generate the text and store the text in the property BEFORE I fetch the text from the property. (The text-generation is HTML produced of a specific XML and XSL. Which XML-document to use is dependent of what the editor selects from the dropdown-box in edit-modus). Best regards Bård Nymoen BEKK Consulting
#13740
Oct 16, 2004 18:11
Vote:
 
Still think you need to handle the Saving or Publishing event. You cannot do this from a user control (or I'm missing the point of what you are trying to do.) You need to handle the events from your global.asax. But remember the events will be called for all pages. What page_load are you talking about exactly? In your template? Steve
#13741
Oct 16, 2004 22:59
Vote:
 
Thanks for the answer. :-) Yes, I am talking about the page_load-method in my Web User Control in the template. I added the code: EPiServer.Global.EPDataFactory.SavedPage += new EPiServer.PageEventHandler(Newsletter_SavedPage); to the InitializeComponent-method in my Web User Control. In this way the Newsletter_SavedPage-method will only be called when the current page is saved. My problem is that this event is called after the page_load-method. I want to do some text-processing in the savedpage-event and save the text in a property. In the page_load method I then want to fetch the generated text from the property. But as said, the order is now opposite. If I put the SavedPage-event handling in the global.asax as you recommended, will this event be called before the page_load-method in my Web User Control? If so, that could be a solution. Best regards Bård
#13742
Oct 17, 2004 20:59
Vote:
 
The SavedPage event is always fired before any Page_Load events. Instead of Page_Load, try Page_PreRender. It is executed when all button events have fired and the page has been saved, but before the page is rendered, so you could do your text-processing there.
#13743
Oct 18, 2004 14:19
Vote:
 
Global.EPDataFactory is a static class that will continue to live until IIS is restarted, its not a class that will die when your request is terminated. This means that if you add events in user controls they will never be detached and you could get a memory leak if you arent careful. It also means that the events you get may come from another request running another control causing really strange behavour under load. The point is: Use Application_Start for events in Global.EPDataFactory or find another solution.
#13744
Oct 19, 2004 9:16
* 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.