Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Aug 06, 2010 @ 11:23
    Ismail Mayat
    1

    On save show popup

    Guys,

    Anyone got example of how to on before save event in backend show a popup, basically want to show a form and capture some data.  It can be done for other events as when you do protect page, roll back etc you get a popup.

    Regards

    Ismail

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Aug 06, 2010 @ 11:40
    Darren Ferguson
    0

    Ismail:

    Not tried but at a guess something like:

    Page page = HttpContext.Current.Handler as Page;

    if (page != null)
    {
         
    Page.Controls.Header.Add(new LiteralControl("javascript in here"));
    }

    Though I'm not sure at what point in the page lifecycle the event handler is called.

    Let me know how you get on.

    This would be an interesting one.

    If you have problems then there is an event that is raised everytime a page in the GUI is rendered.

    You could set a flag on the event and tap into that maybe.

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Aug 06, 2010 @ 11:43
    Morten Christensen
    0

    Hi Ismail,

    I would propose something like:

        public class OnSaveEventSample : ApplicationBase
    {
    public OnSaveEventSample() {
    Document.AfterSave += new Document.SaveEventHandler(Document_AfterSave);
    }

    void Document_AfterSave(Document sender, global::umbraco.cms.businesslogic.SaveEventArgs e)
    {
    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "popup", "<script>\ntop.openModal(yourpopup.aspx?nodeid="+ sender.Id +", 'OnSave Pop Up', 540, 620);</script>");
    }
    }

    - Morten

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Aug 06, 2010 @ 11:48
    Darren Ferguson
    1

    Actually looks as though you should just be able to do:

     

    Page page = HttpContext.Current.Handler as BasePage;

    page.ClientTools.OpenModalWindow(.....)
  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Aug 06, 2010 @ 11:49
    Morten Christensen
    2

    Ups .. and I wrote AfterSave.

    Try it out with Document.BeforeSave += new Document.SaveEventHandler(Document_BeforeSave); instead

    Looking at how the Save-method is setup it would appear that you have access to the same properties as with AfterSave:

            public override void Save()
    {
    SaveEventArgs e = new SaveEventArgs();
    FireBeforeSave(e);

    if (!e.Cancel) {
    base.Save();
    Index(true);
    FireAfterSave(e);
    }
    }

    - Morten

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Aug 06, 2010 @ 11:56
    Ismail Mayat
    0

    Guys,

    Many thanks will try both ways when i get a moment.

    Regards

    Ismail

  • Ismail Mayat 4511 posts 10092 karma points MVP 2x admin c-trib
    Aug 10, 2010 @ 19:05
    Ismail Mayat
    0

    Hello,

    I have this working however when the pop up comes up the page continues to save take it i would before showing popup cancel the event and after doing by bit re fire the event though not sure how i would stop it from looping?

    Regards

    Ismail

  • Darren Ferguson 1022 posts 3259 karma points MVP c-trib
    Aug 11, 2010 @ 09:41
    Darren Ferguson
    0

    I guess you'd need to set a session variable.

    Check if session["cancelPublish"] exists if not then cancel the event and set it.

    If it does exist then null it and continue with the event.

    That way, when your modal re-raises the event it should work.

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    Aug 11, 2010 @ 10:55
    Richard Soeteman
    0

    HI Ismail,

    The properties are saved anyway when you hit the save button. So why not take a different approach. Why not create a custom datatypestore it on the generic properties tab so normal users wouldn't see it  and let that capture the data whenm submitting the form?

    Cheers,

    Richard

Please Sign in or register to post replies

Write your reply to:

Draft