'How to pass other parameters onchange of dropdownlist
I am trying to hit an action on change of Html.DropDownList. I am able to pass the selected value but I need help passing other parameters like Model properties to the js function that gets called onchange of dropdown. Here is my code
@(Html.DropDownList("productSelected", Model.ProductList,
new { onchange= "refreshQueueByPageSize(this.value)" }))
I want to do something like
@(Html.DropDownList("productSelected", Model.ProductList,
new { onchange= "refreshQueueByPageSize(this.value, Model.ProductType)" }))
but doing it this way I get errors while sending the additional parameters to the js function(refreshQueueByPageSize)
Solution 1:[1]
You can get Model.ProductType in js function with @Model.ProductType,so you don't need to pass it to the function:
js:
function refreshQueueByPageSize(value)
{
var [email protected];
}
Update:
If you want to pass c# variable to onchange,try to use:
@Html.DropDownList("productSelected", l,
new { @onchange= "refreshQueueByPageSize(this.value,'"+Model.ProductType+"')" })
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
