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.

" / Code>, the correct path for the "default" category, the sort order "case", the page will be "1": 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

SortOrder in this form, then you have to change your route such as:

< Code> {class} / page {page}

Your URL will be:

http: // SNIP: 7511 / default / Page1? SortOrder = Case

Also keep in mind that you should not usually add the URL yourself. There are built-in support methods such as HtmlHelper 's ActionLink which will do this for you, is consistent with keeping the original URL in the site that you set up Is the way


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -