Dynamic loaded webcontrol instantiation

  • Thread starter Thread starter kw
  • Start date Start date
K

kw

Page X loads WebControl Y which loads WebControl Z.

WebControlZ defines a button:
protected System.Web.UI.WebControls.LinkButton SearchByAssr;

here comes the problem:

private void InitializeComponent()

{

this.Load += new System.EventHandler(this.Page_Load);

this.ButtonZ.Click += new System.EventHandler(this.ButtonZ_Click);//CRASH!
ButtonZ is null



I don't get it...why is ButtonZ null?
 
Accck! Typo, I still have the problem, but I meant to say

protected System.Web.UI.WebControls.LinkButton ButtonZ;
 
How did you load WebControlZ? Check the relative ASCX file of WebControlZ,
is there ButtonZ ? the name should be the same as the codebehind defines.
 
Back
Top