Nevron .NET Vision
Framework / Thin Web / Tools / Postback Tool
In This Topic
    Postback Tool
    In This Topic

    The postback tool allows you to initiate a page postback. Page postback renders the whole page contents and can be useful if you want to update the contents of several controls on the forms. The drawback is that it results in more traffic between the client and the server.

    The following code snippets show how to send a postback when the user clicks on a chart or diagram element:

    C#
    Copy Code

    protected void Page_Load(object sender, EventArgs e)
    {

    if (!NThinChartControl1.Initialized){

    // get the default chart
    NChart chart = NThinChartControl1.Charts[0];

    // add bar serires to the chart
    NBarSeries bar = new NBarSeries();

    chart.Series.Add(bar);

    // add one bar
    bar.Values.Add(10);

    bar.FillStyle = new NColorFillStyle(Color.Blue);
    bar.InteractivityStyle =
    new NInteractivityStyle("Click on me to make me red");

    NPostbackTool postbackTool = new NPostbackTool();
    postbackTool.PostbackOnlyOnInteractiveItems =
    true;

    NThinChartControl1.Controller.Tools.Add(postbackTool);
    NThinChartControl1.Controller.Tools.Add(
    new NTooltipTool());

    }

    NThinChartControl1.Postback += new Nevron.ThinWeb.NPostbackEventHandler(NThinChartControl1_Postback);

    }

    void NThinChartControl1_Postback(object sender, Nevron.ThinWeb.NPostbackEventArgs e)

    {

    NThinChartControl chartControl = (NThinChartControl)sender;

    // hit test

    NHitTestResult hitTestResult = chartControl.HitTest(e.MousePosition.X, e.MousePosition.Y);

    NBarSeries bar = (NBarSeries)chartControl.Charts[0].Series[0];

    if (hitTestResult.ChartElement == ChartElement.DataPoint)

    {

    bar.FillStyle = new NColorFillStyle(Color.Red);

    }

    }

    Nevron Diagram ThinWeb

    C#
    Copy Code

    protected void Page_Load(object sender, EventArgs e)

    {

    if (!NThinDiagramControl1.Initialized)
    {

    // init the document
    NDrawingDocument document = NThinDiagramControl1.Document;

    document.BeginInit();
    document.BackgroundStyle.FrameStyle.Visible =
    false;
    document.AutoBoundsPadding =
    new Nevron.Diagram.NMargins(10f, 10f, 10f, 10f);
    document.Style.FillStyle =
    new NColorFillStyle(Color.White);

    NBasicShapesFactory factory = new NBasicShapesFactory(document);
    NShape circle = factory.CreateShape(BasicShapes.Circle);
    circle.Bounds =
    new NRectangleF(0f, 0f, 200f, 200f);

    // apply interactivity
    circle.Style.InteractivityStyle = new NInteractivityStyle("Click on me to make me red");
    document.ActiveLayer.AddChild(circle);
    NThinDiagramControl1.SizeToContent();

    // configure the controller
    NPostbackTool postbackTool = new NPostbackTool();
    postbackTool.PostbackOnlyOnInteractiveItems =
    true;
    NThinDiagramControl1.Controller.Tools.Add(postbackTool);
    NThinDiagramControl1.Controller.Tools.Add(
    new NTooltipTool());
    }

    NThinDiagramControl1.Postback += new Nevron.ThinWeb.NPostbackEventHandler(NThinDiagramControl1_Postback);

    }

    void NThinDiagramControl1_Postback(object sender, Nevron.ThinWeb.NPostbackEventArgs e)
    {

    NThinDiagramControl diagramControl = (NThinDiagramControl)sender;
    NNodeList affectedNodes = diagramControl.HitTest(new NPointF(e.MousePosition.X, e.MousePosition.Y));
    NNodeList affectedShapes = affectedNodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);

    int length = affectedShapes.Count;

    for (int i = 0; i < length; i++)
    {

    NShape shape = affectedShapes[i] as NShape;

    if (shape != null)
    {
    shape.Style.FillStyle =
    new NColorFillStyle(Color.Red);
    }
    }
    }

     Related Examples

    Chart\Web Forms\ThinWeb\Postback Tool
    Diagram\Web Forms\ThinWeb\Postback Tools