Note that there are some explanatory texts on larger screens.

plurals
  1. POASP (.NET 4) ViewState enabled Literal control not retaining changes to HTML contents on PostBack
    primarykey
    data
    text
    <p>I am populating a <code>ListView</code> with HTML from a database using a <code>Literal</code> with <code>Text='&lt;%#Eval("HTMLData")'%&gt;</code>. When I trigger a PostBack, changes to the loaded HTML are not being reflected in <code>litRowData.Text</code>.</p> <p><code>ViewState</code> is enabled for the page, the <code>ListView</code>, and the <code>Literal</code> in the <code>ItemTemplate</code>, and I am making sure to only populate the <code>ListView</code> with initial values from the database when <code>if(!IsPostBack)</code> is true in <code>Page_Load</code>.</p> <pre><code>&lt;asp:ListView ID="lvForm" runat="server" DataKeyNames="RowID" ItemPlaceholderID="phRow" EnableViewState="true"&gt; &lt;LayoutTemplate&gt; &lt;asp:PlaceHolder ID="phRow" runat="server" /&gt; &lt;/LayoutTemplate&gt; &lt;ItemTemplate&gt; &lt;asp:Literal ID="litRowData" runat="server" Text='&lt;%#Eval("HTMLData")%&gt;' EnableViewState="true"&gt;&lt;/asp:Literal&gt; &lt;/ItemTemplate&gt; &lt;/asp:ListView&gt; </code></pre> <p>I need to be able to capture changes to the contents of the loaded HTML controls. Since this HTML comes from a database table, I can't just use ASP controls inside the <code>ItemTemplate</code>. Can anyone see something I'm missing, or suggest an alternative way to do this?</p> <p><strong>Edit</strong>: To clarify a little more, I'm trying to load form input elements dynamically from a database, render them as HTML controls on the page, allow the user to modify their contents by entering text or selecting options, then capture the modified HTML and save it back to the database when the user clicks a save button.</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.
    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