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?
- 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.
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
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
Sascha. Again, thank you.
I was basicly looking for something like this, clena and simple (something I should have known :o)
No worries, glad I could help out. :)
is working on a reply...