Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Load data from Database into Razor View using Checkbox Checked event

Load data from Database into Razor View using Checkbox Checked event

Scheduled Pinned Locked Moved ASP.NET
databasehtmlasp-netcomhelp
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Enobong Adahada
    wrote on last edited by
    #1

    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

    J 1 Reply Last reply
    0
    • E Enobong Adahada

      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

      J Offline
      J Offline
      jkirkerx
      wrote on last edited by
      #2

      Try searching Google using these words "mvc razor, checkbox event"

      @Html.Checkbox( "somename", new { @onclick="function-to-open-dialog()"})

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups