C
C#2y ago
Cheetah

❔ How do i make user input text appear

public IActionResult ToDo(string Input)
{

Input = ViewBag.UserInput;
ViewBag.UserInput = Input;
return View();
}
public IActionResult ToDo(string Input)
{

Input = ViewBag.UserInput;
ViewBag.UserInput = Input;
return View();
}
@page
@model Webthing.Views.Home.To_doModel

<h1>This is your To Do page</h1>



<form method="post" asp-action="ToDo">
<input type="text" name="Input" /> <!-- Change name to "input" -->
</form>

<center><p>@ViewBag.UserInput</p></center>
@page
@model Webthing.Views.Home.To_doModel

<h1>This is your To Do page</h1>



<form method="post" asp-action="ToDo">
<input type="text" name="Input" /> <!-- Change name to "input" -->
</form>

<center><p>@ViewBag.UserInput</p></center>
this is part of my code rrelating to this so like how do i make UserInput appear on the website? im using cshtml
4 Replies
Pobiega
Pobiega2y ago
its important to understand that you're working with a serverside application here. The web is based on requests and responses So your ASP.NET application will only produce a response once a request is sent
Angius
Angius2y ago
Also, don't use ViewBag. Use proper typed models
Denis
Denis2y ago
Isn't viewbag something from legacy asp.net and not asp.net core?
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?