2

Hi i am just getting into asp.net and SqlServer although have used asp/oracle in the distant past. The following code in the Site.Master file

<!DOCTYPE html>
<html lang="en">
<head runat="server">
  <meta charset="utf-8" />
  <title><%: Page.Title %> - My ASP.NET Application</title>
    <asp:PlaceHolder runat="server">        
      <%: Scripts.Render("~/bundles/modernizr") %>
    </asp:PlaceHolder>

Throws the Error
1 'Scripts' is not declared. It may be inaccessible due to its protection level.'

I'm very slowly getting to grips with the way asp.net does things and any help that can get me over this little hurdle would be much appreciated. Thanks in advance

Michael
  • 21
  • 1
  • 2
  • May be the Scripts directory is not accesible in your project. – Jibran Khan Apr 03 '13 at 12:06
  • Thanks for the quick response, i can see the scripts folder in the solution window and the jquery's etc within it. I assumed that meant it was accessible in the project. Again i'm new to this am i missing a step here? – Michael Apr 03 '13 at 12:26

1 Answers1

3

This utility is provided by the System.Web.Optimization library. Make sure the namespace is provided, otherwise it won't be able to find the Scripts object.

Brian Mains
  • 50,520
  • 35
  • 148
  • 257
  • 1
    Thanks Brian i actually imported that before and a got a webgrease error (so assumed once again i was doing something wrong!) Then found the following http://stackoverflow.com/questions/13619255/ upgrading-webgrease-to-version-1-3-0-gets-me-error So i'll run through the fixes suggested and see where i end up. Thanks again – Michael Apr 03 '13 at 13:11
  • 1
    adding Optimization. in front of my Scripts call fixed my code, thank you! – DForck42 Aug 24 '17 at 15:28