How to keep option after refresh - asp.net

1

I have a select, some options and a jquery code that does not change the select, updates the screen with the data of the chosen option. The question is, how do I maintain the option after the window.location? Note: I'm using Asp.Net

Code that I have:
View:

<select id="servicos">
    @foreach (var i in servicos)
    {
        <option value="@Url.Content("~/servico/"+i.SiteInfoID+"/"+i.Titulo.html)">
            @i.Titulo
        </option>
    }
</select>

Js:

function ComboServicos() {
    $('#servicos').on('change', function () {
        var url = $(this).val();
        if (url) {            
            window.location = url;
        }
        return false;
    });
}
    
asked by anonymous 30.03.2017 / 22:39

1 answer

0

By having the parameter being sent put it in a ViewBag for example and retrieve it in the View so that you can filter by making an if to put the "selected" in the option

    
27.04.2017 / 03:41