views:

38

answers:

0

I am trying to include an Image control within my web part. In CreateChildControls I have the following code:

Image image = new Image();
image.ImageUrl = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "hotline.jpg");

I get a NullPointer exception and this is because 'Page' is null.

Why might this be? Am I doing this all wrong anyway?

More info The web part is under development and is deployed for testing direct from VS2008.

OOPS! This is embarassing. I had split off some code into a separate Panel class which does not have Page set and then tried to access Page in the constructor! Sorry!!