I've been attempting to retrieve a variable using JavaScript and then use it in my C# block, but it seems like it's impossible.
Here is my HTML code:
<select class="form-control" id="Category">
@foreach (var item in Model.Categori)
{
<option value="@item.CategoriId">@item.CategoriName</option>
}
</select>
<div id="Container"></div>
And this is the JavaScript code I'm using:
$('#Category').on('change', function (e) {
$("#Container").append(`@foreach (var item in Model.YetkinlikKategorileri.Where(x => x.Id == $('#Category').val()))
{
<p>hello</p>
}`);
});
Is it possible to achieve something like this? If not, is there another way?