Note that there are some explanatory texts on larger screens.

plurals
  1. POViewstate not preserved when handling exception
    primarykey
    data
    text
    <p>I'm using a detailsview for a dialog to the user, and it seems that the viewstate is not preserved when there is an error inserting the data.</p> <p>I'm using a OnInserted handler on the datasource to check if there was an exception like so:</p> <pre><code>protected void areaInsertHandler(Object sender, SqlDataSourceStatusEventArgs e) { if (e.Exception != null) { // There was an error in submitting, show the error dialog ScriptManager.RegisterClientScriptBlock(Page, GetType(), "DialogHandler", "showError('#overlayAreas');", true); e.ExceptionHandled = true; } } </code></pre> <p>Which simply calls the client side JS function:</p> <pre><code>function showError(overlayName) { $(".msgError").css('visibility', 'visible'); $(overlayName).css('visibility', 'visible'); } </code></pre> <p>My detailsview looks something like this:</p> <pre><code>&lt;asp:UpdatePanel ID="AreaUP" runat="server" UpdateMode="Conditional"&gt; &lt;ContentTemplate&gt; &lt;div id="overlayAreas" class="overlay"&gt; &lt;asp:DetailsView ID="DetailsView_Areas" runat="server" Visible="True" AutoGenerateInsertButton="False" AutoGenerateRows="False" caption="&lt;a style='font-weight: bold;'&gt;Bold&lt;/a&gt; = Required field" CaptionAlign="Bottom" headertext="Create new area" EnableViewState="true" DataKeyNames="Area_Name" DataSourceID="AreasSource" DefaultMode="Insert"&gt; &lt;Fields&gt; ... &lt;/Fields&gt; &lt;/asp:DetailsView&gt; &lt;/div&gt; &lt;br /&gt; &lt;asp:Button width="200" height="30" ID="Button_CreateArea" runat="server" OnClientClick="return btnToggle('#overlayAreas')" Text="Create new area" /&gt; &lt;/ContentTemplate&gt; &lt;/asp:UpdatePanel&gt; </code></pre> <p>It all works fine, but for some reason the ASP viewstate is not preserved. Meaning that if I fill out incorrect information in the form and submit I will get the appropriate error and the dialog will still be displayed. But the fields are not filled out with my old values.</p> <p>If someone could give me some pointers or help me out I'd greatly appreciate it</p> <p>EDIT 10-08: Still haven't been able to solve it, any ideas at all?</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. 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