Change <head> to ASP.NET AJAX

I recently updated my ASP.NET AJAX application. I have two css files in an ASP.NET theme. I use any of css for postback, depending on the state.

Earlier with my non-AJAX ASP.NET application that I used,

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 switched to ASP.NET AJAX. I checked and found that only loaded css from the first request is saved. that is, if a.css loads on first request, and then b.css is required to load on a specific postback.

Please comment if you are confused about the problem.

+1
source share
2 answers

Thanks to Unholy, solved the problem using jQuery and a selector.

:

$("head > link[href$='a.css']").remove();
+1

, UpdatePanel. . . script ScriptManager: ScriptManager.RegisterStartupScript. javascript.

+1

All Articles