Last post May 03, 2005 03:43 AM by rodneyjoyce
Apr 30, 2005 09:54 AM|lilon|LINK
I am writing a module for 2.1.2. The view control is loaded based on a "&itemId=" parameter appended to the url. The module has Edit and Add controls. I use the same ascx page for both (register the same page twice as Add and Edit). Navigation to the Edit
is done by using EditUrl("itemId", itemId, "Edit") and navigation to the Add is done by using EditUrl("itemId", "", "Add"). This goes well.
The problem is going back from both Edit and Add to the view, when clicking update, delete or cancel. I've tried EditUrl("itemId",itemId, "") going back from the Edit, but I get the "mid=number" appended btw the tabid and the itemId and it takes me to an
empty page. Using NavigateUrl will take me to the correct page but without the itemId parameter, so thats no good either.
Also, going back from the Add page I dont have the itemId (I assigned it as -1 to differentiate - I guess in this second case I will have to somehow get the itemId accross).Whats the best way in both cases?
Apr 30, 2005 10:33 AM|walkerstewart|LINK
OK the best, fastest and easiest way to return to the view page is to call the NavigateUrl method without parameters. DNN will then add the current tab id and return you to the page.
EditURL is typically used to go from the view page to an edit screen. Also, instead of having two seperate entries for the add and edit interface, simply pass the id of the item you want to edit and in the Page_Load, check if the parameter is null (then
the page is the add interface), if it isn't null then bind the item related to the item ID.
Check out the DNN Core, Users and ManageUsers interface for a good example of this.
Hope this Helps,
Apr 30, 2005 02:33 PM|rodneyjoyce|LINK
May 02, 2005 02:20 AM|lilon|LINK
Thanks for your answers:
I may not have been clear enough: I have been using the same page for Add and Edit exactly as you have suggested and it does work well. The problem is not there but rather how to get back from the Edit\Add page to the View page, since the view page also
needs an itemId in the url string. If I use NavigateUrl I cannot enter the itemId and if I use the EditUrl then I can add itemId but the method automatically adds the controlId =value and doesnt take me back to the view page but rather to a new page with just
the view control on it. Also if I am trying to get back from the Add page, then I dont have the itemId since I used null in the EditUrl to get from View to Add.
Hope form more ideas....
May 02, 2005 10:11 PM|lilon|LINK
I think I got it how to get back from the Edit page to the view:
Response.Redirect((NavigateURL("")+ "&itemId=" + itemId),
As for the Add page, since currently I am not passing the itemId in the url string when I navigate from the View page to the Add page - I may have to do that (currently I am sending null in the itemId value, so that the page_load in the Add\Edit page will
be able to determine if its Add or Edit). In this case I will just have to find another solution how to notify the page_load if its Add or Edit.
May 02, 2005 11:03 PM|lilon|LINK
May 03, 2005 03:43 AM|rodneyjoyce|LINK