How to pass 2 parameters in asp.net mvc from a dropdownlist

0

I'm trying to pass 2 parameters to the method that is in the controller from the view, but only recognizes the value of the first parameter, the other comes as null, which I'm doing wrong, this is the code.

View

table>
        <tr>
           <% foreach (var item2 in Model)
                { %>
                    <input type="hidden" id="idColegio" value="<%: item2.idColegio %>"  />
                <td><p style="color:black;font-size:medium">Gestiones:</p></td>
                <td><%: Html.DropDownList("gest", new SelectList(ViewBag.gestiones, "Value", "Text"), htmlAttributes: new { @class = "form-control", onchange = "document.location.href = '/CursosOfrecidos/Index?id='+ this.options[this.selectedIndex].value , 'idColegio='+item2.idColegio", style = "width:150px;", @id = "ges", @name = "gestion" }) %></td>                                       
        </tr>         
    </table>

Controller

public ActionResult Index(int id, int? idColegio )
{
    return View(cursoso);
}

Help for fa ...

    
asked by Romer 24.05.2018 в 22:49
source

1 answer

0

The parameters in the QueryString of the URL must not be separated with commas, you must separate them with ampersand and you must also adjust some double and single quotes:

"document.location.href = '/CursosOfrecidos/Index?id='+ this.options[this.selectedIndex].value' + '&idColegio='"+ item2.idColegio
    
answered by 24.05.2018 в 23:59