Search code examples
javascriptasp.netasp.net-mvc-2server-side-includespage-directives

ASP.NET Directive Convention for Declaring Client-Side Includes


I am loading .aspx and .ascx files as StreamReader.

I want each file to register it's javascript and stylesheet dependencies in some declaration like a <%@ ClientDependency path="~/Scripts/jquery-1.4.1.min.js" %>.

Is there an existing convention for doing such a thing? I don't need an implementation, but I don't want to create a new syntax if there is already a way to do it.

Also, what are the guidelines for custom <%@ blocks in ASP.NET?

Also, please retag this question if you can think of a more appropriate description.


Solution

  • There is no existing convention for registering client includes with a directive. My solution was to create a custom server control instead and use the existing TemplateParser functionality to get the include data (which ended up being preferable to loading the file as a stream and parsing it myself).