Answer the question
In order to leave comments, you need to log in
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>
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);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question