All AJAX features of the Nevron web controls require Visual Studio 2005 or later and Microsoft .NET Framework 2 with ASP.NET AJAX Framework 1.0 or Microsoft .NET Framework 3+.
Implement the Nevron.UI.WebForm.Controls.INHttpHandlerCallback interface in a custom class that will handle at the server all events routed by the client. The INHttpHandlerCallback interface mimics all the AJAX events of the web control as callback methods.
In the INHttpHandlerCallback interface implementation provide your custom code that handles the desired events. To get access to the chart/diagram document, cast the event state argument to NChartSessionStateObject/NDiagramSessionStateObject and use the Document property. To perform a hit-test on mouse events, use the HitTest method of the NChartSessionStateObject/NDiagramSessionStateObject state.
In the Page_Load event handler of the page that is hosting the chart/diagram web control add code like this:
myWebControl.HttpHandlerCallback = new MyCustomHttpHandlerCallback();
In Page_Load initialize the chart/diagram web control like this:
C# |
Copy Code
|
---|---|
if (myWebControl.RequiresInitialization) { // add initialization code here } |
Please check Nevron examples for sample source code.
Use a JavaScript like this at the client:
JavaScript |
Copy Code
|
---|---|
function SendMyCustomCommand() { if(typeof(NChartCallbackService) == "undefined") return; var cs = NChartCallbackService.GetCallbackService('ctl07_nChartControl1'); var arguments = new Array(); arguments["arg1"] = "val1"; arguments["arg2"] = "val2"; cs.InvokeCustomCommand('myCustomCommandName', arguments); } |
At the server add an event handler of the AsyncCustomCommand event of the nChartControl1 web control, or, if Nevron Instant Callback is used, implement the OnAsyncCustomCommand interface method of the Nevron.UI.WebForm.Controls.INHttpHandlerCallback interface.
The event handler source code could look like this:
C# |
Copy Code
|
---|---|
protected void nChartControl1_AsyncCustomCommand(object sender, EventArgs e) { NCallbackCustomCommandArgs args = e as NCallbackCustomCommandArgs; switch (args.Command.Name) { case "myCustomCommandName": try { string val1 = args.Command.Arguments["arg1"].ToString(); string val2 = args.Command.Arguments["arg2"].ToString(); // do something with nChartControl1 } catch(Exception ex) { System.Diagnostics.Debug.WriteLine("nChartControl1_AsyncCustomCommand, myCustomCommandName: " + ex.Message); } break; } } |
The OnAsyncCustomCommand source code could look like this:
C# |
Copy Code
|
---|---|
public void OnAsyncCustomCommand(string webControlId, System.Web.HttpContext context, NSessionStateTransport state, NCallbackCustomCommandArgs args) { NChartSessionState chartState = state as NChartSessionState; switch (args.Command.Name) { case "myCustomCommandName": try { string val1 = args.Command.Arguments["arg1"].ToString(); string val2 = args.Command.Arguments["arg2"].ToString(); // do something with chartState.Document } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("OnAsyncCustomCommand, myCustomCommandName: " + ex.Message); } break; } } |
The source code used with Nevron Diagram is very similar. Please check Nevron examples for sample source code.
For usage details and sample code, please refer to the AJAX web examples that are installed by the Nevron .NET Vision installation