We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Diagram ASP.NET modify node label at runtime

How can I change programmatically the node label at runtime in Diagram ASP.Net?


3 Replies

AM Ajeet M Syncfusion Team December 29, 2008 12:07 PM UTC

Hi Ricardo,

To change the Label of the node programmatically, please follow the steps below:

********
1. Assume you have a button to change the Label
2. In the click event you can type the code given below:
------
someNode.Labels[0].Text = "Some_Text_Here";
------

Where, "someNode" is the Node for which you need to change the Label.
********

Let me know if you shall need any further clarifications here.

Happy Coding!

- Ajeet




RG Ricardo Gaona December 29, 2008 12:54 PM UTC

I've tried the following:

1. C#:

protected void DiagramWebControl1_CallbackRefresh(object sender, Syncfusion.Web.UI.WebControls.Shared.CallbackEventArgs e)
{
Node node = DiagramWebControl1.Model.Nodes[e.CallbackArgument];
node.Labels[0].Text = "Some_Text";
}

and gives me an error: Error 23 'Syncfusion.Windows.Forms.Diagram.Node' does not contain a definition for 'Labels'

2. Javascript:

function EditText( ClickedNode )
{
node.Labels[0].Text = "Some_Text";
_sfDiagramWebControl1.Refresh(node.Name);
);

and nothing happens






AM Ajeet M Syncfusion Team December 30, 2008 05:28 AM UTC

Hi Ricardo,

To get the desired functionality, please follow the steps below:

1. In the aspx source, type in the JavaScript for the OnClientNodeClick event as follows:

function NodeClick(node)
{
_sfDiagramWebControl1.Refresh(node.Node.Name);
}

2. Now, in the CS page, under the DiagramWebControl's CallBackRefresh() event handler method, type as follows:

void DiagramWebControl1_CallbackRefresh(object sender, Syncfusion.Web.UI.WebControls.Shared.CallbackEventArgs e)
{
Node node = DiagramWebControl1.Model.Nodes[e.CallbackArgument];
if (node != null)
{
ell = node as Ellipse;
ell.Labels[0].Text = "XYZ";
}
}

I am sure this will resolve your query. Let me know if you shall need any clarifications in this regard.

Happy Coding!
- Ajeet



Loader.
Live Chat Icon For mobile
Up arrow icon