C
C#•7mo ago
Pointman

ASP.NET how does an actionmethod get my model?

details below
No description
11 Replies
Pointman
PointmanOP•7mo ago
so i have this View which uses an incomming model upon clicking "submit", the post method Category/EditCategory() executes
Pointman
PointmanOP•7mo ago
No description
Pointman
PointmanOP•7mo ago
But my question is, how does it obtain the argument "entry"?
Pobiega
Pobiega•7mo ago
through the beauty of "model binding" your <form> tag identities the controller and action it should send the data to
Pointman
PointmanOP•7mo ago
what is this magic 😭
Pobiega
Pobiega•7mo ago
its basic HTML my friend
Pointman
PointmanOP•7mo ago
so the object sent back is the Model used?
No description
Pobiega
Pobiega•7mo ago
a <form> tag with method="post" will send its data in a certain way, essentially a collection of key-value pairs yes but that doesnt actually matter it just lets asp help you more but you could just as well not set a model, and not use asp-for tags etc it would still work, due to how the model binder works
Pointman
PointmanOP•7mo ago
And the <input> tags are used to edit the attributes of the object?
No description
Pobiega
Pobiega•7mo ago
input is what creates an editable control in HTML yes the asp-for tag associates the input with the given model property
Pointman
PointmanOP•7mo ago
:DDDD yeee now my stuff works fine danke schnitzel
Want results from more Discord servers?
Add your server