title: How can I get the routeValue for an actionlink from a textbox? - asp-net core 2.2
body: <p>I wanted to add the sorting and filtering to my Application. (I want to organize some events) When I know search for an event with has an 'a' in it and than want to sort the results, all results are shown again and sorted. </p>
  
  <p>I know, that I have to pass the searchString as a Routeparameter for the Actionlink. But how can I do this?</p>
  
  <p>I found one solution with Request.Querystring but it hadn't work. 
  Someone told me to do it with JavaScript, so I tried to write a function but it didn't work either.
  Can anybody help me? </p>
  
  <p>Excerpts from my code:</p>
  
  <p>Actionlink:</p>
  
  <pre><code>    &lt;h1&gt;events&lt;/h1&gt;
      @using (Html.BeginForm())
      {
      &lt;p&gt;
          &lt;lable&gt;events:&lt;/lable&gt;
          @Html.TextBox("SearchString")
          &lt;input type="submit" value="Search" /&gt;
      &lt;/p&gt;
      &lt;table class="table"&gt;
          &lt;thead&gt;
              &lt;tr&gt;
                  &lt;th&gt;
                      @Html.ActionLink("Titel", "Index", new { sortOrder = ViewBag.NameSortParm}, new { id = action})             
                  &lt;/th&gt;
              &lt;/tr&gt;
          &lt;/thead&gt;
      &lt;/table&gt;
  </code></pre>
  
  <p>JavaScript-Function:</p>
  
  <pre><code>&lt;script&gt;
      $(function () {
          $('#action').click(function () {
              var s = $('#SearchString').val();
              this.href = this.href + '?searchString=' + encodeURIComponent(searchString);
          });
      });
  &lt;/script &gt;
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public async Task&lt;IActionResult&gt; Index(string sortOrder, string searchString)
          {
              ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "titel_desc" : "";
  
              var vs = from t in _context.Events select t;
  
              if (!String.IsNullOrEmpty(searchString))
              {
                  vs = vs.Where(s =&gt; s.Titel.Contains(searchString));
              }
  
              switch (sortOrder)
              {
                  case "titel_desc":
                      vs = vs.OrderByDescending(m =&gt; m.Titel);
                      break;
                  default:
                      vs = vs.OrderBy(m =&gt; m.Titel);
                      break;
              }
              return View(await vs.ToListAsync());
          }
  </code></pre>