Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC - Serializable
    primarykey
    data
    text
    <p>I'm trying to use the new Html helper extension Serialize() from the furthure assembly..</p> <p>If you take a look at:</p> <p>View</p> <pre><code>&lt;%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage&lt;List&lt;MvcApplication2.Models.ProductViewBinding&gt;&gt;" %&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;%@ Import Namespace="Microsoft.Web.Mvc" %&gt;&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml" &gt; &lt;head id="Head1" runat="server"&gt; &lt;title&gt;Index&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt; &lt;% using (Html.BeginForm("Index", "Products", FormMethod.Post)) { %&gt; &lt;% int codeIndex = 0; foreach (var item in Model) { %&gt; &lt;%: Html.TextBox("Encryption[" + codeIndex + "].Value") %&gt; &lt;%: Html.Serialize("Encryption[" + codeIndex + "].ID", item.ID) %&gt; &lt;% codeIndex++; } %&gt; &lt;%: Html.SubmitButton("Click meh!") %&gt; &lt;% } %&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Model</p> <pre><code>[Serializable] public class ProductViewBinding { public object ID { get; set; } [NonSerialized] public object _value; public object Value { get { return this._value; } set { this._value = value; } } } </code></pre> <p>Controller</p> <pre><code>[HttpPost] public ActionResult Index([Deserialize] List&lt;ProductViewBinding&gt; Encryption) { return View("Index", Encryption); } </code></pre> <p>It returns null when posted... but if I remove the [Deserialize] attribute it returns as it should but with the ID still encrypted... Any suggestions for what I might be doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload