Copied to clipboard

Flag this post as spam?

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


  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    May 25, 2011 @ 19:18
    Anthony Dang
    0

    Re-binding on postback - razor running before load?

    I have a razor script in a macro which lists certain content nodes.

    On the same page I have a form (in a user control) which on submit creates a content node in Umbraco.

    My issue is that after postback, my razor script does not show the new added node. If I refresh the page, the new node appears.

    When stepping through, it seems that the razor script is run before btnSubmit_Click in the code behind of my user control. In fact it is running before load

    How do I re-execute the macro after my new node has been created?

     

     

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    May 25, 2011 @ 19:29
    Sebastiaan Janssen
    0

    This is the age-old problem with usercontrols :-) 

    I usually work around it by redirecting back to the current page. You can check for: 

    if(IsPost) {
     //Do some work
     HttpContext.Current.Response.Redirect(Model.Url);
    }
  • Anthony Dang 1404 posts 2558 karma points MVP 3x c-trib
    May 25, 2011 @ 21:13
    Anthony Dang
    0

    That was my first thought, but surely there is a nicer way to do it. I wish there was something like macro.reinit().

     

     

  • Sebastiaan Janssen 5058 posts 15520 karma points MVP admin hq
    May 25, 2011 @ 21:23
    Sebastiaan Janssen
    0

    Unfortunately no, this has been a "problem" for years in Umbraco or even asp.net in general. I look forward to improvements on this in Umbraco 5. For now, you'll have to stick with slightly ugly workarounds.

Please Sign in or register to post replies

Write your reply to:

Draft