I am doing something like 'To do' list, where user can take text and drag into two tables "to do" and "done". First he can create a note. All data is in DB.
model IEnumerable<ToDoList.Models.KtoCo>
@{ ViewBag.Title = "Index"}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<!DOCTYPE HTML>
<html><head><style>#div1, #div2 {
float: left;
width: 500px;
height: 500px;
margin: 10px;
padding: 10px;
border: 1px solid black;
}
</style>
<script>
function allowDrop(ev) {
ev.preventDefault();
}
function drag(ev) {
ev.dataTransfer.setData("text", ev.target.id);
}
function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData("text");
ev.target.appendChild(document.getElementById(data));
}
</script>
@foreach (var item in Model)
{
<div draggable="true" ondragstart="drag(event)" id=@item.Id width="88" height="31">
@Html.DisplayFor(modelItem => item.Kto)
@Html.DisplayFor(modelItem => item.Co)
@Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id = item.Id })
</div>
}
<div id="div1" ondrop="drop(event)" ondragover="allowDrop(event)"> </div>
<div id="div2" ondrop="drop(event)" ondragover="allowDrop(event)"></div>
`
This is my View. And here is a model:
namespace ToDoList.Models
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.Spatial;
[Table("KtoCo")]
public partial class KtoCo
{
public int Id { get; set; }
[StringLength(50)]
public string Kto { get; set; }
public string Co { get; set; }
}
}
The question is: Is there possible way to keep the notes in tables, even after refreshing site?
P.S. I know that the view is not very pretty, i will be working on it later.