How can i make 2 way binding in razor pages?
I nedd to call in:
cshtml Input with value="@test">
cshtml.cs use the value of @test
CodePudding user response:
Here is a sample to bind data in cshtml and cshtml.cs:
cshtml.cs(You can use test value in cshtml.cs with test directly):
public class TestModel : PageModel
{
[BindProperty]
public string test { get; set; }
}
cshtml:
<input asp-for="test"/>
or
<input name="test" value="@Model.test" />
