public class UserInputComponentTestModel : PageModel
{
[BindProperty]
public User UserInMainPage { get; set; }
[BindProperty]
public string Result { get; set; }
public void OnGet()
{
UserInMainPage = new User { Name = "許當麻測試From Main Page", Id = "TESTID", Age = 12 };
}
public IActionResult OnPostSave(string id, string name, int age)
{
Result += id + "," + name + "," + age+" ";
Result += JsonConvert.SerializeObject(UserInMainPage);
return Page();
}
}
Result:
用起來比預期中的簡單 [BindProperty] 設定好之後就連動起來了,而且取得物件也容易
--
Before you read this, the article was in a superposition of human and AI. Upon observation, the wave function collapsed into a sleep-deprived developer.