How do you pass MS Chart Control using ViewState or Application? I’ve tried Application(“mainChart”), but when I try to access it in another page the properties of the object are set to nothing.
PageA.aspx (In a Button.Click Event)
Application("PrintControl") = mainChart
PageB.aspx (Page_Load event)
Dim ChartControl As DataVisualization.Charting.Chart = _
CType(Application("PrintControl"), DataVisualization.Charting.Chart)
When you do
ViewState["Something"]=mychart, thatmychartneeds to be serializable and I doubt that theChartcontrol is serializable; therefore, you won’t be able to put it onViewState. But even if you could put theChartcontrol onViewState, you’d be doing it on the Page you are currently on (PageA.aspx) and not onPageB.aspx.If the only purpose of
PageB.aspxis to provide a printer-friendly version ofPageA.aspx; you should be usingCSSto achieve this. Themedia="print"attribute should help you with that. Read an excellent post regarding this here.