We help IT Professionals succeed at work.

ASP.Net Page.ClientScript.GetWebResourceUrl in Class Error

sbornstein2 asked
I have a basic question should be easy.  I have a WebControl project and I had to create a ITemplate and separate out some of the code for the container.  In my new class it is not a WebControl of course it is an ITemplate.  In that container though I need to have a ImageButton and the ImageURL is a embedded web resource.   My line of code is:

btnSearch.ImageUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(), "MyProject.Control.images.addressbook.gif");

Error is coming up of course:
An object reference is required for the non-static field, method or property 'System.Web.UI.Page.ClientScript.Get'

I beleive it is in the "this.GetType() and I can't have this in here as it is not a page or something.

Watch Question

Hi, just try with the code below once.
using System.Web.UI.WebControls;

btnSearch.ImageUrl = this.Page.ClientScript.GetWebResourceUrl(this.GetType(),"MyNamespace.ResourceTestCS.Resources.Sunset.jpg");

revert me back if problem persist .


No that doesnt work at all the this. just makes Page not even recognized.


no response to my response