There are a couple of ways to do this, but it isn't very necessary.
I have controls that may appear more than once on the page (custom textboxes for eg). If I include the script every time I include the control then things go wrong. I instead use the ScriptManager control to manage these for me.
public partial class PassengerManagement : System.Web.UI.UserControl
{
private const string PassengerManagementJsName = "CustomPassengerManagementJS";
private const string PassengerManagementJsUrl = "/Resources/js/custom.passengerMgmt.js";
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
Type cstype = Page.GetType();
ClientScriptManager cs = Page.ClientScript;
if (!cs.IsClientScriptIncludeRegistered(cstype, PassengerManagementJsName))
cs.RegisterClientScriptInclude(cstype, PassengerManagementJsName, PassengerManagementJsUrl);
}
}
This ensures that the script is included once and only once. I can do the same with
IsClientScriptBlockRegistered
in the same way.
The script manager will be the first control within the form, and that is where the javascript includes and blocks will appear.
As for the css, You should design it in such a way that makes every class, control, named control style are unique so include all css in the Master page header. Either this or include a second ContentPlaceholder in the Master page head so that child pages can add generic css to the page head. Doing this for controls javascript really isn't needed.
I hope that helps ^_^
Andy