I've encountered an issue with a stacked chart component on a c#.net webform from the MS Chart Control Library. Initially, I dragged the control onto the design surface and then proceeded to edit the source html (.aspx page) to assign the element a css class and remove the style attribute that was originally present. This adjustment was made in order to manage the style through the css file rather than using embedded styling. Below is the modified html:
<asp:Chart ID="Chart1" runat="server" DataSourceID="SqlDataSource1" CssClass="smallBarChart"
IsMapAreaAttributesEncoded="True">
In my site.css file, I defined the following rules:
.smallBarChart
{
width: 350px;
height: 230px;
}
However, upon running the web application, I noticed that an "alt style" attribute is being added to the rendered chart component's html. Despite having the correct class attribute, it appears that the information from the undesired "style" attribute is still being utilized. I am puzzled as to why this "style" attribute is being generated by .net. I have removed all style attribute details from the original aspx file and there are no instructions in my code-behind (.cs) file to change the style.
<img id="Chart1" class="smallBarChart" src="/Charts/ChartImg.axd?i=chart_2c39400223fb4933bf5a99e05d6119d4_3.png&g=b5c73578558442d3b9e1dd54cc127f20" alt="" style="height:300px;width:300px;border-width:0px;">
It is crucial for me to manage the style of the chart component solely from my site.css file, hence any suggestions related to inline styling are not viable options. Furthermore, including inline styling (by adding a style attribute to an html element) is considered poor practice!