Load data from Database into Razor View using Checkbox Checked event
-
Hello, I have a TextArea, A submit button and a check box on a Razor view, i want to load some records from the database in to the textarea and then use the submit to send Mesages to the recods loaded. The issue is that i dont know how to load the data using the check box. This is my code so far: the controller: public ActionResult Message(bool loadData) { List _mobile = new List(); if (loadData) { foreach (var item in db.ParentsModels) { _mobile.Add(new SendMessageViewModel { destination = item.mobile+"," }); } } return View(_mobile); } The View code is: @using (Html.BeginForm()) { @Html.AntiForgeryToken()
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.sender, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.EditorFor(model => model.sender, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.sender, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.title, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.EditorFor(model => model.title, new { htmlAttributes = new { @class = "form-control"} }) @Html.ValidationMes
-
Hello, I have a TextArea, A submit button and a check box on a Razor view, i want to load some records from the database in to the textarea and then use the submit to send Mesages to the recods loaded. The issue is that i dont know how to load the data using the check box. This is my code so far: the controller: public ActionResult Message(bool loadData) { List _mobile = new List(); if (loadData) { foreach (var item in db.ParentsModels) { _mobile.Add(new SendMessageViewModel { destination = item.mobile+"," }); } } return View(_mobile); } The View code is: @using (Html.BeginForm()) { @Html.AntiForgeryToken()
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.sender, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.EditorFor(model => model.sender, new { htmlAttributes = new { @class = "form-control" } }) @Html.ValidationMessageFor(model => model.sender, "", new { @class = "text-danger" })
@Html.LabelFor(model => model.title, htmlAttributes: new { @class = "control-label col-md-2" })
@Html.EditorFor(model => model.title, new { htmlAttributes = new { @class = "form-control"} }) @Html.ValidationMes