問題描述
是否有使用 MVC 架構(asp.net、c#、jquery、ajax)自動保存冗長 Web 表單數據的 API/解決方案 (Is there an API/ solution for Auto‑saving data of lengthy web forms using MVC architecture (asp.net,c#,jquery,ajax))
我正在嘗試在我的 Html 代碼中遵循此代碼。在 MVC (ASP.NET) 中自動保存
<div class="form‑horizontal">
<hr />
@Html.ValidationSummary(true)
<div class="form‑group" data‑dirty="false">
@Html.LabelFor(model => model.Username, htmlAttributes: new { onchange = "function()", @class = "control‑label col‑md‑2" })
<div class="col‑md‑10">
@Html.EditorFor(model => model.Username)
@Html.ValidationMessageFor(model => model.Username)
</div>
</div>
<div class="form‑group" data‑dirty="false">
@Html.LabelFor(model => model.Password, htmlAttributes: new { onchange = "function()", @class = "control‑label col‑md‑2" })
<div class="col‑md‑10">
@Html.EditorFor(model => model.Password)
@Html.ValidationMessageFor(model => model.Password)
</div>
</div>
`由於表單足夠長,其中包含 200 多個控件/元素。我嘗試使用本地存儲在客戶端存儲數據,但本地存儲限制為 10 kb 大小。看來我需要在服務器端存儲數據。我必須通過自動保存數據來做以下事情。
當用戶填寫表格時,
參考解法
方法 1:
You will need to use JQuery/Javascript to
- Save data after a time out
- Detect redirect/refresh
- Detect DOM closures
I am not aware of any existing library or ability in MVC to do this.
參考文件