Nevron .NET Vision Documentation
Nevron AJAX How To

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+.

How to switch to AJAX mode
To activate AJAX mode for a Nevron web control, place the control outside any AJAX update panels, then change the value of the AjaxEnabled property of the web control to true from the property browser or set it programmatically to true. You must also have an AJAX-enabled web project and a ScriptManager component present on the web form, where you are using the Nevron web control. The ScriptManager component is a part of the Microsoft ASP.NET AJAX framework for ASP.NET 2.0 and is a built-in control in ASP.NET 3.5.
How to switch to Nevron Instant Callback
  1. 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.

  2. 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.

  3. 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();

  4. 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.

How to send a custom AJAX command with the Nevron web controls

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. 

Examples

For usage details and sample code, please refer to the AJAX web examples that are installed by the Nevron .NET Vision installation

 

 


©2017. Nevron Software LLC.

Send Feedback