title: Creating and showing dynamic error messages (Not working inside UpdatePanel)
body: <p>My web forms inherits a class called <code>MyPageMain</code>, which inhertis <code>System.Web.UI.Page</code> and is located on the <code>App_Code</code> folder.</p>
  
  <p>In this <code>MyPageMain</code> class I created this method, to record and output Exceptions (error messages):</p>
  
  <pre><code>public string Error(Exception pException, string pFriendlyMessage)
  {
      using (BusError erro = new BusError())
      {
          int? errorId = //HERE Routine to log the error;
  
          StringWriter stringWriter = new StringWriter();
  
          using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
          {
  
              writer.AddAttribute(HtmlTextWriterAttribute.Class, "erroMain");
              writer.RenderBeginTag(HtmlTextWriterTag.Div); //&lt;div&gt;
  
              writer.RenderBeginTag(HtmlTextWriterTag.P); //&lt;p&gt;
              writer.Write(pFriendlyMessage);
              writer.RenderEndTag(); // &lt;/p&gt;
              writer.RenderBeginTag(HtmlTextWriterTag.Small); 
              writer.Write("Event tracker:");
              writer.Write(errorId);
              writer.RenderEndTag(); 
  
              writer.RenderEndTag(); // &lt;/div&gt;
              Console.WriteLine(stringWriter.ToString());
          }
  
      }
  }
  </code></pre>
  
  <p>Then, when there is some exception on the page, I call it, like this:</p>
  
  <pre><code>    Protected void btnLoad_Click(object sender, EventArgs e)
      {
           LoadData();
      }        
  
      private void LoadData()
      {
          try
          {
               //Loading some data here.
          }
          catch (Exception ex)
          {
               Error(ex, "Unexpected error trying to load data.");
          }
      }
  </code></pre>
  
  <p>This is bulding OK, but doesn't work... I think that one of the reasons may be the fact that the whole thing is inside an <strong>UpdatePanel</strong>. Any suggestions on how to make this work?</p>
  
  <p>Is this <code>Console.Writeline</code> suitable for what i'm trying to do? Is this going to work on UpdatePanels?</p>
  
  <p>Already Tried with <code>Response.Write(...)</code> and it does work. But not inside an <code>UpdatePanel</code></p>