I moved part of code to the class. Now I get runtime error
<p>I had a working C# 2010 WEB app.<br>
I moved part of code to a new class as follows:</p>

<pre><code>namespace ShowDiagram1
{
    public class MyDraw : WebForm1
    {
        public void DrawPicture () {
            ...
            bitmap.Save(Server.MapPath("pic1.jpg"), ImageFormat.Jpeg);
            Image1.ImageUrl = this.ResolveUrl("pic1.jpg");
             ...
        }
    }
}
</code></pre>

<p>The error message is as follows:</p>

<blockquote>
  <p>Object reference not set to an instance of an object.
  Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.</p>
  
  <p>Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.</p>
  
  <p>Source Error:</p>
  
  <p>Line 85: Image1.ImageUrl = ResolveUrl("pic1.jpg");</p>
</blockquote>

<p>pic1.jpg is created okay in previous line.</p>

<p>Image1 is the element on WebForm1</p>

<p>Thanks.</p>
