さらにアセンブリから新しいHtmlヘルパー拡張Serialize()を使用しようとしています..
あなたが見てみると:
意見
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<List<MvcApplication2.Models.ProductViewBinding>>" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace="Microsoft.Web.Mvc" %>>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Index</title>
</head>
<body>
<div>
<% using (Html.BeginForm("Index", "Products", FormMethod.Post))
{ %>
<% int codeIndex = 0;
foreach (var item in Model)
{ %>
<%: Html.TextBox("Encryption[" + codeIndex + "].Value") %>
<%: Html.Serialize("Encryption[" + codeIndex + "].ID", item.ID) %>
<% codeIndex++;
} %>
<%: Html.SubmitButton("Click meh!") %>
<% } %>
</div>
</body>
</html>
モデル
[Serializable]
public class ProductViewBinding
{
public object ID { get; set; }
[NonSerialized]
public object _value;
public object Value
{
get { return this._value; }
set { this._value = value; }
}
}
コントローラ
[HttpPost]
public ActionResult Index([Deserialize] List<ProductViewBinding> Encryption)
{
return View("Index", Encryption);
}
投稿時にnullを返します...しかし、[Deserialize]属性を削除すると、本来のように返されますが、IDは暗号化されたままです...私が間違っている可能性があることについて何か提案はありますか?