Home How to handle form post from View Component (Razor Core 2)
Reply: 0

How to handle form post from View Component (Razor Core 2)

user826
1#
user826 Published in August 15, 2018, 11:16 am

This weekend a lot of struggle with a View Component.

I try to add a dropdownlist that does an auto postback onchange. This dropdownlist is on a view component.

I have 2 problems:

  1. I don't get the asp-page-handler after the post, does it work like I implemented it on the form-tag?
  2. Post calls method public void OnPost on razor page containing view component. I would think it would be better to have a method on the View Component like OnChangeProject?

The code of my View (View Component):

<form asp-page-handler="ChangeProject" method="post">

    @Html.AntiForgeryToken()
    @Html.DropDownList("id", new SelectList(Model, "Id", "Id"), new { onchange = "this.form.submit()" })

</form>

Thanks in advance!!

You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO