Использование radio buttun asp.net

Есть небольшая форма

@page
@model IndexModel
@{
    ViewData["Title"] = "BotDirector";
}
<div class="row">
    <form method="post">
    <div class="col-md-3">
        <h2>Start explorers</h2>
        <ul>
            <li>
                <select name="faction" asp-for="Faction" >
                    <option selected="true">@(Factions.Sentinels)</option>
                    <option>@(Factions.Legion)</option>
                </select>
                <input type="number" asp-for="BotExplorerToStart"/><input type="submit" value="Run"/>
            </li>
            <ul>
                <input type="radio" name="gender" value="Add" /> Add bots
                <input type="radio" name="gender" value="Stop" /> Stop bots
            </ul>
            <h3><a href="http://localhost:8167/ExplorerStop">Stop all explorers</a></h3>
        </ul>
    </div>
    </form>
    </div>

Управляется следующим кодом

    public class IndexModel : PageModel
    {
        private readonly IBotDirectorService directorService;
        private readonly ILogger<IndexModel> logger;

        public IndexModel(ILogger<IndexModel> logger, IBotDirectorService directorService)
        {
            this.logger = logger;
            this.directorService = directorService;
        }

        [BindProperty] public int BotExplorerToStart { get; set; }

        [BindProperty] public Factions Faction { get; set; }

        [BindProperty] public bool IsStopped { get; set; }

        public async Task<IActionResult> OnPostAsync()
        {
            try
            {
                if (!this.IsStopped)
                    await this.directorService.StartBots(this.BotExplorerToStart, BehaviorType.Explorer, this.Faction, masteryLevel: 1);
                else
                    await this.directorService.StopExplorerBots();
            }
            catch (Exception ex)
            {
                this.logger.Error(ex);
            }

            return this.RedirectToPage("/Index");
        }
    }
}

Как мне сделать так, чтобы при переключении radiobutton у меня менялось значение переменной IsStopped?


Ответы (0 шт):