Issue
i can't find anything that tells me how to display data to a text area from a database or textbox
Solution
how to display data to a text area from a database
You can refer to the below demo.
Controller:
public IActionResult Index()
{
TextInputModel model = new TextInputModel();
model.list = new List<string> { "answer1", "answer2", "answer3" };
model.Name = "aa";//you can get your data from batabase too...
return View(model);
}
TextInputModel:
public class TextInputModel
{
public List<string> list { get; set; }
public string Name { get; set; }
}
Index view:
@model TextInputModel
<div class="form-group">
<label class="control-label">List</label>
<textarea name="list" class="form-control" style="text-align:right">@string.Join("\n ", Model.list)</textarea>
</div>
<div class="form-group">
<label class="control-label">Name</label>
<textarea name="Name" class="form-control" style="text-align:right">@Model.Name</textarea>
</div>
I have text boxes and a submit button when the button is pressed it must display to the text area
I create a view to show text box and a view display data to a text area.
Controller:
public IActionResult Show()
{
return View();
}
[HttpPost]
public IActionResult Show(string Name)
{
ViewBag.Name = Name;
return View("ShowText");
}
Show view:
<form method="post" asp-action="Show">
<input type="text" name="Name"/>
<input type="submit" value="Submit"/>
</form>
ShowText view:
<textarea name="Name" class="form-control" style="text-align:right">@ViewBag.Name</textarea>
Answered By - Qing Guo Answer Checked By - Senaida (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.