title: Is there any native way in ASP.NET to do a "success message"?
body: <p>Say you have something like an ASP.NET ASP:DetailsView to show and edit a single record in a database.</p>
  
  <p>It's simple to record the error cases... you add validation and a validation summary.  When your update form fails validation it naturally makes noise: it shows the validation message and/or the validation summary.  Not a single code behind is required.</p>
  
  <p>But then, you pass validation, and it makes your update completely silently.  There's no sense that anything happened, and there doesn't seem to be any default settings to make a success message without code-behinds.</p>
  
  <p>But, even code-behinds are confusing.  What event should show the success message?  onItemUpdate, right?  Fine, but then let's say you make another change and get a validation error?  Your success message stays.  I wasn't able to find an event that would reliably turn off an existing success message if there were a validation error.  </p>
  
  <p>This should be web development 101!  Why is it so hard?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Someone suggested using the ItemCommand event... I tried this and many other events, but that success message just won't disappear.  Here's some code.</p>
  
  <p>My message in ASP.NET</p>
  
  <pre><code>&lt;label id="successMessage" class="successMessage" runat="server"&gt;&lt;/label&gt;
  </code></pre>
  
  <p>And my DataView tag (simplified):</p>
  
  <pre><code>    &lt;asp:DetailsView 
          Id="EditClient"
          DataKeyNames="LicenseID" 
      DataSourceID="MySource"
      runat="server" 
          OnItemUpdated="SuccessfulClientUpdate"
          OnItemCommand="ClearMessages"&gt;
  </code></pre>
  
  <p>And, my code-behind:</p>
  
  <pre><code>protected void SuccessfulClientUpdate(object sender, DetailsViewUpdatedEventArgs e)
  {
      successMessage.InnerText = string.Format("Your changes were saved.");
      successMessage.Visible = true;
  }
  
  protected void ClearMessages(object sender, DetailsViewCommandEventArgs e)
  {
      successMessage.InnerText = string.Empty;
      successMessage.Visible = false;
  }
  </code></pre>
  
  <p>Once I do a successful update, however, nothing seems to make that message disappear, not even failed validation.</p>
  
  <p><strong>2nd EDIT:</strong></p>
  
  <p>Just want to be clear that I did try putting the ClearMessages code in Page_Load.  However, nothing seems to make that successMessage label disappear when I hit update a 2nd time WITH a validation error.  Can anyone suggest any other troubleshooting tips?</p>