This is a migrated thread and some comments may be shown as answers.

Compile Error while getting build-in webresource in rad control

3 Answers 96 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Youka
Top achievements
Rank 1
Youka asked on 10 Jul 2012, 08:14 PM
Hi, all

I tested the skin function of RAD AJAX control and met with a problem on loading webresource, here is the original link of the article.
http://www.telerik.com/help/aspnet-ajax/introduction-skins-external-assembly.html

I tried to read an image from build-in RAD Control,  and add a css code block like below. (In fact, I test this because I want to show a custom html element with it's style consistent with different skins in RAD)
.style1
{
    background-image:url('<%=WebResource("Telerik.Web.UI.Skins.Black.Common.loading.gif")%>');
    width: 100%;
}

But unfortunately the page won't compile and report a CS0118 error:
CS0118: Telerik.Web.UI.WebResource is a 'type' but is used like a 'variable'.

My question is, where exactly "WebResource" method is defined in asp.NET? how to solve this error while telerik control itself has a "WebResource" Class?

Thanks in advance.

3 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Zhekov
Telerik team
answered on 13 Jul 2012, 02:41 PM
Hi.

I am attaching a sample page how this can be done in a page. Using Telerik built-in resources in css files is trickier and not that straight forward.

Greetings,
Ivan Zhekov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Youka
Top achievements
Rank 1
answered on 15 Jul 2012, 09:48 AM

Thanks Ivan Zhekov,

I Succeeded to get the resource picture by adding a function in code behind like
protected string GetWebResURL(Type type, string ResName)
{
...
}

also your solution works too :)

I am just still curious where is "WebResource()" function defined. ....I searched object browser in VS but found nothing.
0
Ivan Zhekov
Telerik team
answered on 16 Jul 2012, 08:52 AM
Hi, Youka.

The WebResource method comes from the framework itself. There is a nice thread over at StackOverflow that might give you more information on the matter -- http://stackoverflow.com/questions/1196747/how-to-reference-embedded-images-from-css.

All the best,
Ivan Zhekov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
General Discussions
Asked by
Youka
Top achievements
Rank 1
Answers by
Ivan Zhekov
Telerik team
Youka
Top achievements
Rank 1
Share this question
or