Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Allan Michaelsen 14 posts 33 karma points
    Mar 05, 2011 @ 14:19
    Allan Michaelsen
    0

    Using "umbraco.library.RegisterStyleSheetFile"

    Hi all

    I was wondering how to use the mentionaed library function. I took it out of a xslt filem exchanged the colon for a dot but the script won't save.

    Error occured

    error CS1502: The best overloaded method match for 'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)' has some invalid arguments

    Not really saying much about the real error. The code looks like this:

    @umbraco.library.RegisterStyleSheetFile("ImageSlider", "/css/umb_imageslider.css");

     

  • Sebastiaan Janssen 4841 posts 14344 karma points MVP admin hq
    Mar 07, 2011 @ 18:08
    Sebastiaan Janssen
    1

    You have to put this code in a code block like so:

    @{
     umbraco.library.RegisterStyleSheetFile("ImageSlider", "/css/umb_imageslider.css");
    }
  • Allan Michaelsen 14 posts 33 karma points
    Mar 08, 2011 @ 08:53
    Allan Michaelsen
    0

    Hi Sebastiaan

    That worked perfectly, so i thought i'd do the same for umbraco.library.RegisterClientScriptBlock.

     

    @{
      umbraco.library.RegisterJavaScriptFile("jquery-1.4.4.min", "/scripts/jquery-1.4.4.min.js");
      umbraco.library.RegisterJavaScriptFile("jquery.nivo.slider.pack", "/scripts/jquery.nivo.slider.pack.js");
      umbraco.library.RegisterClientScriptBlock("nivoslider", "<script type='text/javascript'>$(window).load(function(){$('#slider').nivoSlider({controlNav:false,effect: 'slideInRight'});});</script>", true);
    }

    The first two lines get registered fine, but not the scriptblock.

  • Allan Michaelsen 14 posts 33 karma points
    Mar 08, 2011 @ 22:33
    Allan Michaelsen
    0

    I figured it out. It's a known bug where you need to have a form with runat="server" on the page befor it loads the scriptblock. But even when i put a form on the page to test it didn't work right. I guess i'll have to wait for the bugfix.

    /Allan

  • Aaron Powell 1708 posts 3043 karma points c-trib
    Mar 08, 2011 @ 23:07
    Aaron Powell
    0

    If you're dynamically registering JavaScript files (or CSS files) you need to have a runat="server" on your head element otherwise you're likely to hit problems.

Please Sign in or register to post replies

Write your reply to:

Draft