11168 : How do I use a CSS file with the GTP.NET?

Question

How do I use a CSS file with the GTP.NET?

Answer

Normally you do not want to add a css of your own to change the styles of the grid since one is generated for you based on the settings of the CellLayouts. This way you can have almost the same view in WinForms and ASP.NET.

The class names of the cells is taken from the names of the used CellLayout. You can choose to use an External style sheet or a style sheet section in the rendered page.

This property comes into play: ExternalStyles, When setting ExternalStyles to true the css stylesheet is NOT embedded into the rendered html. Intstead you must add an attribute to the head section. You will also need to create the theganttstyles.css and you can do this by calling UpdateExternalStyles with the file name of your choice. If you leave ExternalStyles to false (default) you do not need this, but on the other hand ajax does not update the head section so under certain circumstances you can run into troubles using embedded styles. 

UpdateExternalStyles,  When setting ExternalStyles to true the css stylesheet is NOT embedded into the rendered html.

Typical scenario for when to create to the css file:
Gantt_ASP_Main.ExternalStyles=true; // You have decided to use external styles, this might be set in the object inspector already LoadMainProjectData(); // You fill the Gantt with data AND you probably create some CellLayouts format grid cells
if (!File.Exists(Page.MapPath(“GanttStyle.css”))) // If you have no need for dynamic styles, the file does not need to be written every time… Gantt_ASP_Main.UpdateExternalStyles(Page.MapPath(“GanttStyle.css”)); // This call reads the CellLayouts and create the css content, and saves the file.