Jump to content
Software FX Community

how to render webControl for chart


dolsol
 Share

Recommended Posts

hi

i want creating dynamic chart. so, i used webControl to chart.

i maked webControl 'ExWebChart .cs' 

next source ..

  [DefaultProperty("ID")]

  [ToolboxData("<{0}:ExWebChart runat=server></{0}:ExWebChart>")]

  public class ExWebChart : WebControl

  {

public ExWebChart() { }

private void RenderToPage(HtmlTextWriter writer)

  {

ChartFX.WebForms.Chart createChart = new ChartFX.WebForms.Chart();

createChart.ID = "Chart1";

  createChart.RenderFormat = ".NET";

  createChart.RenderControl(writer);

    }

}

i add webControl in Page.

next source...

  public partial class WebForm1 : System.Web.UI.Page

  {

  protected void Page_Load(object sender, EventArgs e)

  {

  Page.Controls.Add(new ExWebChart());

  }

  }

after excute IE, i see html source.

 <html xmlns="http://www.w3.org/1999/xhtml" >

<head><title>

</title</head>

<body>

  <form name="form1" method="post" action="WebForm1.aspx" id="form1">

<div>

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNzgzNDMwNTMzZGSlm9e254TPxC0VY9mLgBJ8oYXLhw==" />

</div>

  <div>

 

  </div>

  </form>

</body>

</html>

<script src="/chartfx70/temp/CFT0226_1044241280F.js" mce_src="/chartfx70/temp/CFT0226_1044241280F.js"></script>

<script>cfx_replaceChart1();</script>

Like to see,  it is not exists next source

<input type="hidden" name="_Chart1_pers" id="_Chart1_pers" value="" />

<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />

<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />

<input type="hidden" name="__Chart1_VIEWSTATE" id="__Chart1_VIEWSTATE" value="CFV0226_1052003C813.chs" />

<script src="/WebResource.axd?d=FoKpfpQHHw6Hf71HRQDHRw2&t=633681528857031250" mce_src="/WebResource.axd?d=FoKpfpQHHw6Hf71HRQDHRw2&t=633681528857031250" type="text/javascript"></script>

<script src="/WebResource.axd?d=TdymIgps6GvgTCnkoSb1Qa1OUDE2egYuMl-xc5grG0jz7u3ExLDk64aLPX68LmhkqXJWMtSZQ0D3KlB_4auCLA2&t=633679730980000000" mce_src="/WebResource.axd?d=TdymIgps6GvgTCnkoSb1Qa1OUDE2egYuMl-xc5grG0jz7u3ExLDk64aLPX68LmhkqXJWMtSZQ0D3KlB_4auCLA2&t=633679730980000000" type="text/javascript"></script>

<script type="text/javascript">

<!--

function SFX_Callback (chartId, clickId) {

WebForm_DoCallback(chartId,clickId,SFX_OnCallbackReady,chartId,SFX_OnCallbackError,true);

}

function SFX_PostBack (chartId, clickId) {

__doPostBack(chartId,clickId);

}

// -->

</script>

what's wrong!!  plz, tell me heros

Link to comment
Share on other sites

When Custom Chart created is wrapped in a WebControl and dinamically created in the asp.net page, the code generated is not the same, becuase the chart is now completely handled from the server side. The Web Control asumes all the chart responsibility and hides additional code buecause it is executed in the server. If you drag and drop a chart to the asp.net page, it will create some javascript functions to handle events. With a WebControl this is not necesary because the chart is handled within the WebControl not directly in the webpage.

 Hope this solves your interrogant. 

Also, this is my code to render a chart dinamically;

---------------------- CONTROL ----------------------

public class DynamicChart : System.Web.UI.WebControls.WebControl
{
  public DynamicChart()
  {
    //
    // TODO: Add constructor logic here
    //
  }

  protected override void RenderContents(HtmlTextWriter writer)
  {
  base.RenderContents(writer);
  ChartFX.WebForms.Chart vNewChart = new ChartFX.WebForms.Chart();
  vNewChart.RenderFormat = ".Net";
  vNewChart.Height = 300;
  vNewChart.Width = 400;
  vNewChart.RenderControl(writer);
  }
}

---------------------- ASP.NET PAGE ----------------------

 

protected void Page_Load(object sender, EventArgs e)
  {
  DynamicChart vChart = new DynamicChart();
  MyDiv.Controls.Add(vChart);

  }

 

MyDiv is div registered in the server, like this:

<form id="form1" runat="server">
  <div id="MyDiv" runat="server">  
  </div>
</form>

Link to comment
Share on other sites

very very..  thanks frank for your reply ! 

I will try to develop the contents to see what you told me. i need that to create some javascript functions to handle events.

So, Can you help me. i need simple sample source. For example, 'Click Event' How can I do to develop.

 

waiting for your reply..

 

 

ChartFx7_bug.zip

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.

 Share

×
×
  • Create New...