Copied to clipboard

Flag this post as spam?

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


  • Halldór Hrafn Gíslason 30 posts 50 karma points
    Sep 21, 2010 @ 12:07
    Halldór Hrafn Gíslason
    0

    Navigating with User controls

    Hi,

    I'm building a website which will use quite a bit of user controls (due to specialized forms, lists, etc.)

    Now I'm wondering what would be a practical thing to do when navigationg between pages, concreate or conceptual.

    For example, let's say that I have a simple form that a user is submitting. How would I (in C#) make him move to the previous page (from where he requested the form). I presume I would specify it in the PostBackUrl property of my submit button, but what would be the best way to get the previous page info, from Umbraco's point of view?

    Thanks,
    Halldór Hrafn

  • Sascha Wolter 615 posts 1101 karma points
    Sep 21, 2010 @ 12:33
    Sascha Wolter
    0

    Hi Halldor,

    couple of hints:

    - you can get the 'previous' page by using Request.UrlReferrer; e.g. save it in the ViewState when the page is not posted back; use with care though as it might not be working as exact as you wish it to

    - how about sending the url to redirect back to in the query string, e.g. '/form?redirectTo=/my-referrer-page'; have a default when this is empty; this is lightweight and flexible

    - you don't want to use PostBackUrl on the submit button of the form. The form should postback to itself so you can do something with the entered data on the page with the form on it, then use Response.Redirect to redirect the user if everything is fine with the form.

    Hope that helps,

    Sascha

  • Halldór Hrafn Gíslason 30 posts 50 karma points
    Sep 21, 2010 @ 12:44
    Halldór Hrafn Gíslason
    0

    Sascha. Again, thank you.

    I was basicly looking for something like this, clena and simple (something I should have known :o)

  • Sascha Wolter 615 posts 1101 karma points
    Sep 21, 2010 @ 12:58
    Sascha Wolter
    0

    No worries, glad I could help out. :)

Please Sign in or register to post replies

Write your reply to:

Draft