Guys,
I have recently upgraded to ASP.NET AJAX application. I have two css files in an ASP.NET theme. I use any one of the css per postback depends upon a condition.
Previously with my non-AJAX ASP.NET application, what I used to do is
protected void Page_PreRender(object sender,
EventArgs eventArgs)
{
ControlCollection headCollection = Header.Controls;
for (int i = 0; i < headCollection.Count; i++)
{
Control temp = headCollection[i];
if (temp is HtmlLink)
{
if (/* condition to loads a.css */)
{
if (((HtmlLink) temp).Href.EndsWith("a.css", true, null))
{
headCollection.RemoveAt(i);
break;
}
}
else
{
if (((HtmlLink) temp).Href.EndsWith("b.css", true, null))
{
headCollection.RemoveAt(i);
break;
}
}
}
}
}
But this piece of code does not work when I migrated to ASP.NET AJAX. I have inspected and found that only the loaded css from the first request persists. i.e., if a.css is loaded on the first request, and then b.css is required to be loaded on a specific postback does not work.
Please comment if you are confused about the problem.