Compile Error while getting build-in webresource in rad control

4 posts, 1 answers
  1. Youka
    Youka avatar
    3 posts
    Member since:
    Jul 2012

    Posted 10 Jul 2012 Link to this post

    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.
  2. Answer
    Ivan Zhekov
    Admin
    Ivan Zhekov avatar
    649 posts

    Posted 13 Jul 2012 Link to this post

    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.
  3. Youka
    Youka avatar
    3 posts
    Member since:
    Jul 2012

    Posted 15 Jul 2012 Link to this post


    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.
  4. Ivan Zhekov
    Admin
    Ivan Zhekov avatar
    649 posts

    Posted 16 Jul 2012 Link to this post

    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.
Back to Top