U
U
Urope2021-04-07 06:13:39
ASP.NET
Urope, 2021-04-07 06:13:39

What should I do if the button click does not work?

I wrote the markup, which is located at Views/Home/Index:

<form asp-controller="Home" asp-action="Index" method="post">
div class="demo-btns">
<div class="info">
<div class="buttons">
<p><input type="text" name="userName" placeholder="Name:" size="18" /></p>
<p><input type="text" name="roomCode" placeholder="Code of the room:" size="18" /></p>
<input type="submit" class="modal__trigger2" value="Join Room" />
</div>
</div>
</div>
</form>


Here is the controller:
public class HomeController : Controller
    {
        [HttpGet]
        public IActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public IActionResult Index(string userName, string roomCode)
        {
            string data = $"Username: {userName}, Roomcode: {roomCode}";
            return Content(data);
        }
    }


I click on the button, but nothing happens. What to do?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question