我有我使用的MSChart我的MVC項目時出現問題,當我使用項目的第一個索引頁,以渲染索引2的代碼部分視圖名稱是的MSChart:局部視圖錯誤
<% Html.RenderPartial("Index2"); %>
但是,當我運行它的錯誤是發生該消息是
CS0029:無法隱式轉換類型「ASP.views_home_index2_ascx」到「System.Web.UI.Page」
- 它說,問題行代碼
://渲染圖表控制
第52行:Chart2.Page = this; < <在這裏
線53:HtmlTextWriter的作家=新 的HtmlTextWriter(Page.Response.Output);
第54行:Chart2.RenderControl(writer);
但是當我把所有的代碼Index2.ascx到的Index.aspx,而不是渲染局部視圖它做工精細
Index2.ascx的代碼是
<%
System.Web.UI.DataVisualization.Charting.Chart Chart2 = new System.Web.UI.DataVisualization.Charting.Chart();
Chart2.Width = 412;
Chart2.Height = 296;
Chart2.RenderType = RenderType.ImageTag;
Chart2.Palette = ChartColorPalette.BrightPastel;
Title t = new Title("No Code Behind Page", Docking.Top, new System.Drawing.Font("Trebuchet MS", 14, System.Drawing.FontStyle.Bold), System.Drawing.Color.FromArgb(26, 59, 105));
Chart2.Titles.Add(t);
Chart2.ChartAreas.Add("Series 1");
Chart2.Series.Add("Series 1");
// add points to series 1
Chart2.Series["Series 1"].Points.AddY(3);
Chart2.Series["Series 1"].Points.AddY(4);
Chart2.Series["Series 1"].Points.AddY(5);
Chart2.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;
Chart2.BorderColor = System.Drawing.Color.FromArgb(26, 59, 105);
Chart2.BorderlineDashStyle = ChartDashStyle.Solid;
Chart2.BorderWidth = 2;
Chart2.Legends.Add("Legend1");
// Render chart control
Chart2.Page = this;
HtmlTextWriter writer = new HtmlTextWriter(Page.Response.Output);
Chart2.RenderControl(writer);
%>