Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've been thinking about a workaround for the problem, and I've found one.</p> <p>I inject an extra parameter into the querystring collection. That way I can put the search filter into the querystring.</p> <p>Normally the querystring collection is readonly, but I've found some code to fix this. </p> <p>Code to add parameter to querystring:</p> <pre><code> public static void Add(string name, string value) { NameValueCollection qs = System.Web.HttpContext.Current.Request.QueryString; qs = (NameValueCollection)System.Web.HttpContext.Current.Request.GetType().GetField("_queryString", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(System.Web.HttpContext.Current.Request); PropertyInfo readOnlyInfo = qs.GetType().GetProperty("IsReadOnly", BindingFlags.NonPublic | BindingFlags.Instance); readOnlyInfo.SetValue(qs, false, null); qs[name] = value; readOnlyInfo.SetValue(qs, true, null); } </code></pre> <p>New controller code:</p> <pre><code> public ActionResult Index(string SearchFilter) { // check querystring search if (string.IsNullOrEmpty(SearchFilter) &amp;&amp; !String.IsNullOrEmpty(Request.QueryString["search"])) SearchFilter = Request.QueryString["search"]; var model = new Models.SubscriptionListModel { SearchFilter = SearchFilter }; if (string.IsNullOrEmpty(SearchFilter)) { model.SubscriptionList = _subscriptionHandler.ReadWhereIdLessThanThousand(); } else { // add search filter to the querystring Common.QueryString.Add("search", SearchFilter); model.SubscriptionList = _subscriptionHandler.ReadWhereContains(SearchFilter); } if (Request.IsAjaxRequest()) { return View("SubscriptionList", model); } else { return View("Index", model); } } </code></pre> <p>If anyone has a cleaner solution to fix this, suggestions are still welcome :-)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload