ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  asp.net install chart at design time or runtime
Posted by icm63 on Jun-02-2011 04:08
There are two ways to show a control in asp.net 2.0 that I use.

In both cases the control is registered on the aspx page.

Control1 = ChartDirector ChartType1
Control2 = ChartDirector ChartType2


ONE DESIGN TIME

In the ASPX page I have in design time

<div id="divMyControls" runat="server">
  <uc1:Control1 id="Control1" runat="server" />
  <uc2:Control2 id="Control2" runat="server" />
</div>

IN the codebehind I have in the page_load, that runs from the information from a query string

Select case ControlType
case is = 1
   Me.Control1.Visble = True
   Me.Control2.Visble = False
      With me.Control1
         .Load = loadData
      End with
case is = 2
   Me.Control1.Visble = False
   Me.Control2.Visble = True
      With me.Control2
         .Load = loadData
      End with
End Select

NO matter the control (or charttype selected) the chartdirector always displays.

The Issue with the approach is that setting control visible property to true or false does not stop code running in either control set visible = false (This is slow)

TWO RUN TIME

In the ASPX page I have in design time

<div id="divMyControls" runat="server"></div>

IN the codebehind I have in the page_load, that runs from the information from a query string

Select case ControlType
case is = 1
       Dim myDisplay As Control1= CType(LoadControl("~/controls/Control1.ascx"),Control1)
     Me.divMyControls.Add(myDisplay)
      With myDisplay
         .Load = loadData
      End with
case is = 2
       Dim myDisplay As Control2= CType(LoadControl("~/controls/Control2.ascx"),Control2)
     Me.divMyControls.Add(myDisplay)
      With myDisplay
         .Load = loadData
      End with
End Select

The approach adds the control in runtime to the divMyControls. In each ascx control the page_load has the chartdirector build code, so its in sync with the aspx page that its added to. This is a better approach as no code runs in controls that are NOT required (ie visisble = false).

The problem is the chartdirector "WebChartViewer" does NOT render, it flashes a white box ( ie it trying to render) then collapses. So NO chart shows up. The code in the chart control is the same no matter if its design time or  run time, so its the same control. I know the data is loaded into to, I also know the code gets down to :

WebChartViewer1.ImageMap = c.getHTMLImageMap("", "", showText)

As I have tested that.. it does not show a chart with this approach.

NOTE: The chart control has other asp.net controls with in it and they are populated from data from SQL tables and XML and they populate ok. Just  that chart does not draw.

Why not, what can I do, test , any ideas??

  Re: asp.net install chart at design time or runtime
Posted by icm63 on Jun-02-2011 04:10
When I say control I means the chart director

<PF1chart:WebChartViewer ID="WebChartViewer1" runat="server" />

Is installed on a asp.net ascx or usercontrol.

  Re: asp.net install chart at design time or runtime
Posted by Peter Kwan on Jun-03-2011 04:44
Hi icm63,

Setting Visible to true or false will not cause any code to run or not run. In VB syntax, the If/Then statement can be used to control whether some code is run.

If ...xxx... Then
   ... Run some code ...
End If

If you add the WebChartViewer control dynamically late in the WebForm life cycle (on or after PageInit), then you would need to manually add the following code in the PageInit event handler:

WehChartViewer.OnPageInit(Me)

You may refer to the documentation on WebChartViewer.onPageInit for more details.

Hope this can help.

Regards
Peter Kwan