Instead of a *.cs code behind or beside I’d like to have a *.js file. I’m developing a MVC application an have no need for a code beside because I have controllers, but in certain cases it’d be nice to have a JavaScript code beside or some way to associate the file to the page it’s being used on. I suppose I could just name them similarly, but I’m wanting to show the association if possible so there’s no question about what the file is for.
Typically what I’m talking about is within Visual Studio now under your Global.asax file you will have a plus sign to the left:
+ Global.asax
Once you expand it you’ll get
- Global.asax Global.asax.cs
I’d like the same thing to happen:
+ Home.spark - Home.spark Home.spark.js
Updated:
My existing csproj file has a path to the actual file, not sure if that’s screwing it up. I’ve currently got:
<ItemGroup> <Content Include='Views\User\Profile.spark.js'> <DependentUpon>Views\User\Profile.spark</DependentUpon> </Content> </ItemGroup> <ItemGroup> <Content Include='Views\User\Profile.spark' /> </ItemGroup>
and it’s simply just showing the files besides each other.
Absolutely – but you’ll have to edit the project file by hand. Find your ‘child’ file’s entry, and change it to be a non-self-closing element, and add a child element to say what it depends on. Here’s an example for a .cs file being compiled:
And here’s a version I’ve just mocked up for the files you’ve specified – although I expect
Home.sparkwill have an action associated with it rather than ‘None’:Visual Studio displays it just as you’d expect it to.