c# - Passing one parameter of multiple to controller -
I am trying to sort a list while maintaining the current page view. I have created a PageHolver class and sortellar class to do this. The problem is that instead of passing only the parameters, the controller needs it to be passing the whole end of the URL. How can I root it so that the correct parameters are passed?
sorthelper.cs:
public static MvcHtmlString PageSort (This is HtmlHelper HTML, string LinkText, string sortOrder, string category, pagingInfo paginginfo, fx & lt; int, string & Gt; pageUrl) {// Model Referee Number of pages to get paging in. StringBilder result = new stringbilder (); {// href Tag Builder Editor per Page = New Tag Builder ("a"); // a & lt; A & gt; Tag tag Merge author ("href", "? Sort order =" + sorted + page url (paginginfo.sink page)); Tag INHML = link text; Tag.AddCssClass ("selected"); Result.Append (tag.ToString ()); } // Dynamically creates links - href + pagenumber = URL returns as string MvcHtmlString.Create (result.ToString ()); }
link from Entries.cshtml:
@ HTML.PageSort ("Case", "Case", Model ._CurrentCategory, Model.PagingInfo, x = & Gt; Url.Action ("Entries", New {page = Model.PagingInfo.CurrentPage, category = Model._CurrentCategory}))
Route:
For routes. New {sortOrder = @ "\ [AZ]" page = @ \ "new"), new {sort = "" {{class} / {sort order} / page {page} ", new {controller =" entry ", action =" entries} D + "});
When I sort, I get the following link:
http: // SNIP : 7511 /? SortOrder = Case /? Page = 1
The required parameter in this example will be "case" only, but instead I am getting "case / page = 1". My initial idea is to filter the URL with regedx in the controller , But I think I am reversing it and probably not using the route config properly.
Is this routing, controller, or helpful thing? how?
Thank you!
Edit Thank you for the info, obviously, I was confused with it.
; Th & gt; @ Html.route link ("case", "new", {class = model.content category, sort order = "case", page = Model.PagingInfo.CurrentPage}) & lt; / Th & gt;
This has worked, but apparently my DB is leaving the back space in all the entries, so this is a different issue that I have to face.
http: // SNIP: 7511 /
, with the original URL: < P> http: // SNIP: 7511 / default / Case / Page 1
Note that you do not have to specify the variable name in the URL, it's OK to do routing What does it - shows how some parts of the URL can be variable A is mapped (as well as the controller and director of operations).
? SortAuder =
form is actually a different way of obtaining variable passing in this form, in this form, you will not include sortOrder
in your path, but you can do this as a parameter in your action method can see. These can only come in the last part of your URL, for example if you want specifically in
Comments
Post a Comment