venus najad

venus najad

  • 1.3k
  • 414
  • 29.1k

Delegate to an instance method cannot have null 'this'.

Jul 27 2023 10:15 PM

hellol everyone... i have created a dynamically ImageMap which by clicking on it, it opens another page. but i dont know how i define. i am using these codes, buti get an error: Delegate to an instance method cannot have null 'this'.

 ImageMap ImageMap1 = new ImageMap();
            ImageMap1.Height = 150;
            ImageMap1.Width = 150;
            ImageMap1.ImageUrl = GridView1.Rows[rowind].Cells[11].Text;
            ImageMapEventHandler imgMap_Click = null; //if i do not put it to null, it asks in the next row: 
            ImageMap1.Click += new ImageMapEventHandler(imgMap_Click); // use of unassinged local variable
            tcell_2.Controls.Add(ImageMap1);
            trow_2.Controls.Add(tcell_2);
            mytable.Controls.Add(trow_2);

 

protected void imgMap_Click(object sender, ImageMapClickEventArgs e) 
        {...}

 

appreciate and thankful your respond, kind regards


Answers (4)