Jump to content
Software FX Community

.NET client control events not firing


eatlbd

Recommended Posts

I am using ChartFX 7 Build 7.0.3306.26568; 30Jan2009 in VS2005 with .NET 2.0 SP2 on XP Professional SP3.

I have not been able to get any event to fire in the development environment or deployed to IIS when the chart was rendered as a .NET control. The events fired when rendered as images in Firefox or when RenderFormat was not specified (hence default to image) in Internet Explorer.

I simply dropped a chart on to an aspx page and added the ChangedByUser event:

<chartfx7:Chart ID="Chart1" runat="server" RenderFormat="Auto" OnChangedByUser="Chart1_ChangedByUser">

<Titles>

<chartfx7:TitleDockable Text="Original" />

</Titles>

<Series>

<chartfx7:SeriesAttributes />

<chartfx7:SeriesAttributes />

<chartfx7:SeriesAttributes />

</Series>

</chartfx7:Chart>

and the only custom code in the .cs file is as follows:

 protected void Chart1_ChangedByUser(object sender, ChangedByUserEventArgs e)

{

this.Chart1.Titles[0].Text = "Modified";

}

I had put debug lines in all event handlers that are accessible at design-time and all of them seem to behave the same as to when they would fire. Basically, fired when in FF or as an image in IE but not when the chart was rendered as .NET control.

Any pointers?

 

Link to comment
Share on other sites

Hi,

When chart is rendered as .Net, it becomes an Active X. As any other activex control, it is completely downloaded client side. So, server events are not straight visible. In this case, you should use SFX callbacks through javascript in order to send and bring data from the server.

This is an example:

you can capture toolbar and menu events using the UserCommand event.

in you asp.net page copy this between the </head> .... <body> tags:

<script lang="JavaScript" for="Chart1" event="UserCommand(obj, args)">

  if(args.CommandID == 1)
  {
  clientChart = document.getElementById('Chart1');
  if (clientChart.Chart) 
  clientChart = clientChart.Chart;
 
  clientChart.Series.Item(0).Gallery = 2;
 
  }
  </script>

...

...

<chartfx7:Chart ID="Chart1" runat="server" UseCallbacksForEvents="True" RenderFormat=".Net">
</chartfx7:Chart>

 

You can also handle this in code behind like this:

 

 <script type="text/javascript">

  function doLoadCallback()
  {
SFX_SendUserCallback('Chart1','Load',false);    
  }  
 
  function doCommandCallback()
  {
SFX_SendUserCallback('Chart1','Command1',false);    
  }  
 
  </script>

...

...

...

<chartfx7:Chart ID="Chart1" runat="server" OnUserCallback="Chart1_UserCallback" UseCallbacksForEvents="True">
  </chartfx7:Chart>

 

On code behind.....

  public void Chart1_UserCallback(object sender, UserCallbackEventArgs e)
  {
  if (e.Param.Equals("Load"))
  {
  Chart1.Series[0].Color = System.Drawing.Color.Red;  
  }
  else {
  if (e.Param.Equals("Command1")) {
  Chart1.Series[0].Color = System.Drawing.Color.Pink;
  }
  }  
  }

post-5270-13922409698962_thumb.jpg

Link to comment
Share on other sites

Thanks for the reply. I've not been able to get it to work though. 

I assume if I want to do the equivalent of what I was going to do with the ChangedByUser event, I would use the following code in the .aspx between the tags </head> and <body>:

<script lang="JavaScript" for="Chart1" event="ChangedByUser()">

  clientChart = document.getElementById('Chart1'); 

if (clientChart.Chart)

  clientChart = clientChart.Chart;

  clientChart.Titles[0].Text = "Modified";

</script>

This is a little further than I can test yet as I got this error in VS2005 IDE that says"lang", "for" and "event" aren't valid attributes for element 'script'. So I'm not surprised that the event didn't seem to be handled when I ran it.

I'm using IE7. Does it matter?

Is there any documentation on the matter that I can read to find out more on how to do these?

Thanks again.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...