1

I am developing a web application and I have this Bundle Config

using System.Web;
using System.Web.Optimization;

namespace WebApplication3
{
    public class BundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/WebFormsJs").Include(
          "~/Scripts/WebForms/WebForms.js",
          "~/Scripts/WebForms/WebUIValidation.js",
          "~/Scripts/WebForms/MenuStandards.js",
          "~/Scripts/WebForms/Focus.js",
          "~/Scripts/WebForms/GridView.js",
          "~/Scripts/WebForms/DetailsView.js",
          "~/Scripts/WebForms/TreeView.js",
          "~/Scripts/WebForms/WebParts.js"));

        bundles.Add(new ScriptBundle("~/bundles/MsAjaxJs").Include(
            "~/Scripts/WebForms/MsAjax/MicrosoftAjax.js",
            "~/Scripts/WebForms/MsAjax/MicrosoftAjaxApplicationServices.js",
            "~/Scripts/WebForms/MsAjax/MicrosoftAjaxTimer.js",
            "~/Scripts/WebForms/MsAjax/MicrosoftAjaxWebForms.js"));

        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include(
                    "~/Scripts/jquery-ui-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.unobtrusive*",
                    "~/Scripts/jquery.validate*"));

        }
    }
}

This is one of my view page:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
      <title></title>
<script>
 <-- This?? -->
</script>

how can i render the bundles? I am using Asp.net Web Application using asp.net aspx view

3 Answers 3

3

You use for MVC:

@Scripts.Render("~/bundles/WebFormsJs")

And for WebForms:

<%: Scripts.Render("~/bundles/WebFormsJs") %> 
Sign up to request clarification or add additional context in comments.

Comments

2

Can check like this.

@Scripts.Render("~/bundles/WebFormsJs")  
@Scripts.Render("~/bundles/MsAjaxJs")  
@Scripts.Render("~/bundles/jquery")  
@Scripts.Render("~/bundles/jqueryui")  
@Scripts.Render("~/bundles/jqueryval")  

Comments

1

This should do the trick
Make sure Microsoft ASP.Net Web Optimization Framework is installed your project.

 <script src="<%=BundleTable.Bundles.ResolveBundleUrl("~/bundles/jqueryui")%>" type="text/javascript"></script>
 <script src="<%=BundleTable.Bundles.ResolveBundleUrl("~/bundles/jquery")%>" type="text/javascript"></script>

4 Comments

i am receiving error The name 'BundleTable' does not exist in the current context same wih the script.render 'Script' does not exist in the current context
I have installed the nuget Microsoft ASP.Net Web Optimization already
@JohnPaulCirilos use <%@ Import Namespace="System.Web.Optimization" %> on your page
i got it, configured my web.config

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.