title: asp.net core razor pages onpost set value of textbox
body: <p>i am new to asp.net core, i am working with basic razor page and trying to issue onpost via submit button , then have a public property that is binded to the page get set to a specific value from the onpost. here is my code below. But when i click on the submit button the post happens but nothing gets updated? how can i get the test1 when it's set in the OnPost to &quot;this should work&quot; back on the page in the textbox ?</p>
  <p>Index.cshtml</p>
  <pre><code>@page
  @model IndexModel
  @{
      ViewData[&quot;Title&quot;] = &quot;Home page&quot;;
  }
  
  &lt;div class=&quot;text-center&quot;&gt;
      &lt;h1 class=&quot;display-4&quot;&gt;Welcome&lt;/h1&gt;
      &lt;p&gt;Learn about &lt;a href=&quot;https://docs.microsoft.com/aspnet/core&quot;&gt;building Web apps with ASP.NET Core&lt;/a&gt;.&lt;/p&gt;
  &lt;/div&gt;
  
  &lt;form method=&quot;post&quot;&gt;
      &lt;label&gt;testing&lt;/label&gt;
      &lt;input asp-for=&quot;@Model.test1&quot; type=&quot;text&quot; /&gt;
      &lt;br /&gt;
      &lt;br /&gt;
      &lt;input id=&quot;Submit1&quot; type=&quot;submit&quot; value=&quot;submit&quot; /&gt;
  
  &lt;/form&gt;
  </code></pre>
  <p>then my Index.cshtml.cs</p>
  <pre><code>namespace WebApplication1.Pages
  {
      [BindProperties]
      public class IndexModel : PageModel
      {
          private readonly ILogger&lt;IndexModel&gt; _logger;
  
          public IndexModel(ILogger&lt;IndexModel&gt; logger)
          {
              _logger = logger;
          }
  
       
          public string test1 { get; set; }
  
          public void OnGet()
          {
              
           
          }
  
          public IActionResult OnPost()
          {
  
              test1 = &quot;this should work&quot;;
  
              return Page();
          }
  
  
  
      }
  }
  </code></pre>