Issue
i can't find anything that tells me how to display data to a text area from a database or textbox without using runat or tells me how to use run at, what i am trying to do is this , I have text boxes and a submit button when the button is pressed it must display to the text area , I've tried run at , I've googled and I can't find a straight answer that shows me how to do it.
I've tried the run at method doesn't work nor does it pop up.
I've tried googling and no luck
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
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.