How to prevent web forms for marketers from entering their own jquery-ui.custom.Default.css

I used Web forms for marketers (WFFMs) at Sitecore recently, and I noticed that he introduced:

<link href="/sitecore%20modules/shell/Web%20Forms%20for%20Marketers/themes/colors//jquery-ui.custom.Default.css" rel="stylesheet" type="text/css" /> 

Is there a way to disable the link so that only the CSS files that I specified are added to the page?


After looking at more of the WFFM source, I noticed that an unwanted <link /> added to the page via Page.Header.Controls :

 if (page.Header != null) { if (!flag) { try { //possibly added as link, unless an exception is thrown page.Header.Controls.Add((Control) htmlLink); linkDictionary.Add(key, key); continue; } catch (Exception ex) { //added manually HtmlTextWriter writer = new HtmlTextWriter((TextWriter) new StringWriter(new StringBuilder())); htmlLink.RenderControl(writer); page.ClientScript.RegisterClientScriptBlock(typeof (Page), writer.InnerWriter.ToString(), writer.InnerWriter.ToString()); flag = true; continue; } } } 

This means that I can check all the header controls and hide the one that contains "jquery-ui.custom.Default.css" , but it still looks like a dirty-nasty hack (what it is). It will also not remove the link in situations where page.Header.Controls.Add exception.

+4
source share
2 answers

Web forms for marketers will not actually add the <link> tag if the stylesheet is missing from the file system.

The main problem was that TDS cached a copy of the deleted stylesheet and added it to the web directory on each build. Clearing the assembly and clearing the cached TDS files fixed the problem without having to add server-side code.

+2
source

I decompiled WFFM and it does not seem to be able to be modified to change it or disable it. So, one way to get around this problem is to edit this file directly and destroy its contents. It will still be loaded, but will not contain CSS.

UPDATE

In your updates, you can also try something like this:

 Control ctl = WebUtil.FindControlOfType(Sitecore.Context.Page.Page, typeof(TYPE-OF-EXPECTED-CONTROL)); 

Where do you replace TYPE-OF-EXPECTED-CONTROL . From here you can do whatever you want, for example, find out if there is a link to enable CSS, etc.

+2
source

Source: https://habr.com/ru/post/1396472/


All Articles