0

I've tried really hard to include a JavaScript file with my WebPart as a resource. The web part class and the flexidgrid.js file are both in the root level of the project. The Web Part is created in DisplaySearchResults.js:

namespace DisplaySearchResults
{

    public class DisplaySearchResults :  WebPart
    {

        ### Hidden Irrelevant Stuff Here ###


        protected override void CreateChildControls()
        {
            ### Hidden Irrelevant Stuff Here ###


            ### Load JavaScript Code Here ###

            string scriptURL = Page.ClientScript.GetWebResourceUrl(typeof(DisplaySearchResults), "DisplaySearchResults.flexigrid.js");
            ClientScriptManager cs = Page.ClientScript;

            if (!cs.IsClientScriptBlockRegistered(ByeByeIncludeScriptKey))
                cs.RegisterClientScriptInclude(this.GetType(), ByeByeIncludeScriptKey, scriptURL);
        }

            ### Hidden Irrelevant Stuff Here ###


    }


}

The AssemblyInfo.cs for DisplaySearchResults looks like this:

[assembly: WebResource("DisplaySearchResults.flexigrid.js", "text/javascript")]

But for some reason the WebResource.axd file still comes up as 404.

starblue
  • 55,348
  • 14
  • 97
  • 151
Warren J Thompson
  • 408
  • 1
  • 7
  • 19

2 Answers2

0

Make sure that file's Build Action is set to "Embedded Resource" in the properties for that file.

Dave Ward
  • 59,815
  • 13
  • 117
  • 134
0

I had already set the Embedded Resource - it turned out I needed the fully qualified Assembly name - Company.UI.Web.DisplaySearchResults - which I got from right clicking on the properties menu of the project. On the application tab, there is the proper Assembly name.

So, instead of:

[assembly: WebResource("DisplaySearchResults.flexigrid.js", "text/javascript")]

I should have put:

[assembly: WebResource("Company.UI.Web.DisplaySearchResults.flexigrid.js", "text/javascript")]
Warren J Thompson
  • 408
  • 1
  • 7
  • 19