I am trying to get the values from a form from an action link but there always null for example I have two dropdowns, where are in a for loop I have a edit button at the end of the row to post to the below controller as such.
The Edit button is simply a link asp-button But when I pass OIC1 and OIC2 their values are null in the controller action. Also as the model is not saved yet will the model binding have the right values if the user changes the selections in the dropdowns
?
The anchor will have the model value at render, it will not depend on the drop down. You could do a post rather than a like to the drop down values. Otherwise write JavaScript to update the links href on the selects change event.
How would i have a form inside my loop though is that allow is it legal to do that as it would be a form each row can you provide an example ?
bruce (sqlwork.com)
The anchor will have the model value at render, it will not depend on the drop down. You could do a post rather than a like to the drop down values. Otherwise write JavaScript to update the links href on the selects change event.
The anchor will have the model value at render, it will not depend on the drop down. You could do a post rather than a like to the drop down values. Otherwise write JavaScript to update the links href on the selects change event.
I found out that the items in the loop where being named differently ie they would be named
name="item.id" they must be the normal name for the binding to work.
roguenidb
I am trying to get the values from a form from an action link but there always null for example I have two dropdowns, where are in a for loop I have a edit button at the end of the row to post to the below controller as such.
The Edit button is simply a link asp-button But when I pass OIC1 and OIC2 their values are null in the controller action. Also as the model is not saved yet will the model binding have the right values if the user changes the selections in the dropdowns
?
Member
16 Points
131 Posts
Action link not passing route parameters to controller.
Jul 21, 2020 02:54 PM|roguenidb|LINK
I am trying to get the values from a form from an action link but there always null for example I have two dropdowns, where are in a for loop I have a edit button at the end of the row to post to the below controller as such.
The Edit button is simply a link asp-button But when I pass OIC1 and OIC2 their values are null in the controller action. Also as the model is not saved yet will the model binding have the right values if the user changes the selections in the dropdowns ?
All-Star
58124 Points
15641 Posts
Re: Action link not passing route parameters to controller.
Jul 21, 2020 02:59 PM|bruce (sqlwork.com)|LINK
The anchor will have the model value at render, it will not depend on the drop down. You could do a post rather than a like to the drop down values. Otherwise write JavaScript to update the links href on the selects change event.
Member
16 Points
131 Posts
Re: Action link not passing route parameters to controller.
Jul 21, 2020 03:02 PM|roguenidb|LINK
How would i have a form inside my loop though is that allow is it legal to do that as it would be a form each row can you provide an example ?
Member
16 Points
131 Posts
Re: Action link not passing route parameters to controller.
Jul 21, 2020 03:32 PM|roguenidb|LINK
For some reason I tried the following but my properties are comming though null.
The form Loop
Member
16 Points
131 Posts
Re: Action link not passing route parameters to controller.
Jul 21, 2020 03:55 PM|roguenidb|LINK
I found out that the items in the loop where being named differently ie they would be named
name="item.id" they must be the normal name for the binding to work.