Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The way postback works in .NET is actually a wrapper around the more basic idea of HTML forms. A basic example of HTML forms is:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;form action="" method="POST"&gt; &lt;input type="text" value="type here" /&gt; &lt;input type="submit" value="go" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Roughly, what the .NET abstraction adds is:</p> <pre><code>&lt;html&gt; &lt;body&gt; &lt;form action="" method="POST"&gt; &lt;input type="hidden" name="__VIEWSTATE" value="string-encoded-value" /&gt; &lt;input type="text" name="bob" value="type here" /&gt; &lt;input type="submit" value="go" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Whereby on postback to your page, all input elements with names are mapped back into properties of your Page object, and the <code>__VIEWSTATE</code> hidden field is deserialized into all properties of objects that do not correspond to values of html <code>input</code> tags. For example, if <code>Page.bob</code> had a <code>DateTime</code> property associated with it, it would be stored in <code>__VIEWSTATE</code> possibly.</p> <p>ASP.NET <code>Literal</code> tags in Page markup will get printed into the browser exactly as is, meaning that if you have <code>&lt;span&gt;bob&lt;/span&gt;</code> as its value, that is how it will appear within the <code>&lt;form&gt;</code> tag. However, in plain HTML world, <code>&lt;form&gt;</code> tags when posted will only contain the values of certain form elements (aka not every <code>div</code>, <code>span</code>, <code>p</code> etc. gets posted back, only <code>input</code>, <code>select</code>, <code>textarea</code> and some others). So if your literal doesn't contain an <code>input</code> then it won't even get posted back meaning <code>__VIEWSTATE</code> will be used to restore the <code>Value</code> property of the <code>Literal</code> back to its initial state.</p> <p>To fix this, you probably don't want to stick html into a <code>Literal</code> because even if you do it's not clear that it will get associated with the right property of your page. Instead, try a <code>TextBox</code> element or something else that gets written as an <code>input</code> element directly by the ASP.NET webforms code. Alternatively, try using javascript to allow modifications of flat text in divs if you don't need to persist the data.</p>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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