I am working on a code project in asp.net MVC. I have a problem with redirecting the user after completing one task. I have these controllers:
Index search page:
The Public Performance Index ( ) {// This method sets the view-model data for search preferences Viewmodel obj = new Viewmodel (); // Set the value of the dropdown and see back search capabilities ("search", obj); }
The user then fills the search box in the scene, chooses the dropdown. This will return a post search method that handles data:
[HTTP post] Public ActionStrust Index (see Modell Ojj, int page) Select DB. Database in data = IB; If (! String.IsNullOrEmpty (obj.Example) {data = data.Where (x => x.poss == obj.poss);} // PAGING and other data formatting see here ("Results", Data );}
When the results list is displayed, I have a checkbox / button system that results in the result of the user selecting many results and "good", "bad" etc. There is a method that changes the database very easily. My problem is that the data changes after the database, I'm not sure How to return the user back to set the exact result. A method that gives zero work, and the criteria are not separated (a complete view model), so I can not just save the URL and send them Back to URL, I want to keep the view-model as a parameter. How can I save the view-model data, which can be used later for their search preferences Including the page method without making changes to my method:
[HTTP post] Public activity dex (string dropdown 1, string dropdown 2, int Nom ......) {}
what I did in the session The visual model was saved. Then I deserialize in index method Something like this in the index method:
[HTPGet] Public Action Result Advanced Search () {HTTP Contact Current Context = System. Web. Hptpt Advanced Search Search Model Adwords SearchViewModel = (Advanced SearchwomanModel) session ["Advanced Search Model"]; If (advancedSearchViewModel == zero) {advancedSearchViewModel = new Advanced SearchViewModel (); AddAdvancedSearchLists (Advanced Search Search Model, CurrentContax); } See Return (Advanced Search Search Model); }
Some code has been provided to save the session in the post:
session ["Advanced Search Search Model"] = Advanced Search Search Model;
Note that if you have listboxes (drop down and multiple selections), you will need to recreate the listbobs in the post method and select Selection (multi select ) HTML Stateless does not send MVC lists back to the server on the post, it sends only what was selected.
No comments:
Post a Comment