title: How do get value of razor textbox in the same view?
body: <p>I am using `@Html.Textbox("searchString") in Razor view page. I need this value of textbox in </p>
  
  <pre><code>@Html.ActionLink("View Items", "Index", new { id = item.transaction_id, searchString = "Value of textbox"}).
  </code></pre>
  
  <p>Of course the search string part in html action link is not working right now but i need this as i have specific route which works according to search string. </p>
  
  <p>How do i pass value of textbox to action link?</p>
  
  <p>i check this <a href="https://stackoverflow.com/questions/1856518/passing-textbox-value-using-html-actionlink">this</a>,<a href="https://stackoverflow.com/questions/12183799/how-to-pass-a-value-from-textbox-as-parameter-to-action">this</a>,<a href="https://stackoverflow.com/questions/11293048/how-to-pass-textbox-value-using-html-actionlink-in-asp-net-mvc-3">this</a> and <a href="https://stackoverflow.com/questions/15587733/get-textbox-value-for-ajax-actionlink-in-mvc-4-razor">this</a>.</p>
  
  <p>What i tried is </p>
  
  <pre><code>&lt;script type = "text/javascript"&gt;
  var value = document.getElementbyID("searchString").Text;
  var link =  @Html.ActionLink("View Items", "Index", new { id = item.transaction_id, searchString = -1});
  link.replace(-1,value);
  &lt;/script&gt;
  </code></pre>
  
  <p>Still no luck. I understand Razor renders at server side.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>i have following textbox on the top of view:</p>
  
  <pre><code>    @using (Html.BeginForm("Index", "trans_junction", FormMethod.Get))
  {
  &lt;p&gt;
      Request No: @Html.TextBox("searchString")
      &lt;span&gt;&lt;input type="submit" value="Search Request" /&gt;&lt;/span&gt;
  &lt;/p&gt;
  }
  </code></pre>
  
  <p>This textbox is search box in which user can search items.</p>
  
  <p>there is an Action link as follows:</p>
  
  <pre><code> @Html.ActionLink("View Items", "Index", new { id = item.transaction_id }) |
  </code></pre>
  
  <p>and a route config:</p>
  
  <pre><code>public class RouteConfig
  {
      public static void RegisterRoutes(RouteCollection routes)
      {
          routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  
          routes.MapRoute(
              name: "Default",
              url: "{controller}/{action}/{id}/{searchString}",
              defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional, searchString= UrlParameter.Optional }
          );
      }
  }
  </code></pre>
  
  <p>Now i need to pass the values as my route map via actionlink. As suggested in answer by StephenMuecke, i tried to modify my <code>@using (Html.BeginForm("Index", "trans_junction", FormMethod.Get))</code> with <code>@using (Html.BeginForm("Index", "trans_junction", new { id = item.transaction_id }, FormMethod.Get))</code>
  but item is not accessible there. </p>
  
  <p>When user click search button, url is <code>http://localhost:57286/trans_junction/Index?searchString=20</code></p>
  
  <p>if user click on Action link url is <code>http://localhost:57286/trans_junction/Index/88</code></p>
  
  <p>but i actually need is <code>http://localhost:57286/trans_junction/Index/88/20</code></p>
  
  <p>which preserve the the result of search and also pass the id.</p>
  
  <p>I am adding screenshots for better understanding. </p>
  
  <p>This is index view without search.</p>
  
  <p><a href="https://i.stack.imgur.com/KzMxa.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/KzMxa.jpg" alt="enter image description here"></a></p>
  
  <p>This is search result with searchString = 10.
  <a href="https://i.stack.imgur.com/KF0ms.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/KF0ms.jpg" alt="enter image description here"></a></p>
  
  <p>This is after clicking the action link i.e. View Items, Here search results are not preserved.
  <a href="https://i.stack.imgur.com/InCkj.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/InCkj.jpg" alt="enter image description here"></a></p>