Home Bind input date value to page model Razor
Reply: 0

Bind input date value to page model Razor

Mohamad Al Asmar
1#
Mohamad Al Asmar Published in 2017-12-07 09:22:34Z

I am using razor pages, I want to bind the value of this input to the page model

<input type="date" class="form-input" name="date" id="date" />

Note that I don't have a controller here.

I have tried to add attribute value="@Model.MyDate.date" and define a type for it like this:

public class MyPageModel : PageModel {

 [BindProperty]
 public MyDate Date { get; set; } 
 // use my date value here
}
public class MyDate
 {
    public string date { get; set; }
 }

but still unable to understand how this binding works, if I want to put this value in TempData or use it in my model or pass it to next view, please help me!

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.299514 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO