SharePoint: Why is the Page property in my web part null?
Posted
by paul
on Stack Overflow
See other posts from Stack Overflow
or by paul
Published on 2010-06-01T13:17:21Z
Indexed on
2010/06/01
13:23 UTC
Read the original article
Hit count: 113
I am trying to include an Image control within my web part. In EnsureChildControls 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?
© Stack Overflow or respective owner