I am currently exploring the possibility of reading script tags within the PreRender event of a master page. I have been successful in extracting CSS links, but I am facing difficulties with script tags.
The following code successfully retrieves CSS links:
foreach (var c in HeadElement.Controls)
{
var link = c as HtmlLink;
if (link != null)
{
var url = new Uri(link.Href, UriKind.RelativeOrAbsolute);
if (url.IsAbsoluteUri == false)
{
System.Diagnostics.Debug.WriteLine(url);
}
}
}
However, I have noticed that script tags are not present in the control collection, and they cannot be found in the ScriptManager.GetCurrent(Page)
Script collection either (which seems to fetch the AjaxControlToolkit ScriptManager).
If anyone has any suggestions or tips, I would greatly appreciate it!
Just to clarify, the script tags on the master page are standard, not added dynamically or via a script manager.
Here is an example of the HTML Markup:
<head id="HeadElement" runat="server">
...
<link href="/css/normalize.css" rel="stylesheet" />
<link href="css/jquery.ui.timepicker.css" rel="stylesheet" />
...
<script src="/Scripts/bowser.js" type="text/javascript"></script>
...
</head>