Dundas Chart for ASP.NET
ViewStateData Property
See Also  Example Send comments on this topic.
Dundas.Charting.WebControl Namespace > Chart Class : ViewStateData Property


Gets or sets the user-defined view state of the control.


User defined control state data in XML format.

Syntax

Visual Basic (Declaration)  
Public Property ViewStateData As String
Visual Basic (Usage) Copy Code
Dim instance As Chart
Dim value As String
 
instance.ViewStateData = value
 
value = instance.ViewStateData
C#  
public string ViewStateData {get; set;}

Return Value

A string value that represents the view state of the control, which is embedded in the web document at the client.

Example

The following example manages the state of the control, and the user-defined view state consists of the chart's appearance properties.

Visual Basic Copy Code
Imports System.IOImports Dundas.Charting.Webcontrol
...

If IsPostBack Then

    ' Load the posted appearance data into the control
    Dim sr As New StringReader(Chart1.ViewStateData )
    Chart1.Serializer.Content = SerializationContent.Appearance
    Chart1.Serializer.Load(sr)

Else

    ' Save the appearance view state data
    Dim sw As New StringWriter()
    Chart1.Serializer.Content = SerializationContent.Appearance
    Chart1.Serializer.Save(sw)
    Chart1.ViewStateData = sw.ToString()

End If
C# Copy Code
using System.IO;
using Dundas.Charting.Webcontrol;
...

if(IsPostBack){
   
   
// Load the posted appearance data into the control
   
StringReader sr = new StringReader(Chart1.ViewStateData );
   Chart1.Serializer.Content = SerializationContent.Appearance;
   Chart1.Serializer.Load(sr);

}
else{
   
   
// Set the user-defined view state
   
StringWriter sw = new StringWriter();
   Chart1.Serializer.Content = SerializationContent.Appearance;
   Chart1.Serializer.Save(sw);
   Chart1.ViewStateData = sw.ToString();

}

Remarks

This property allows for greater flexibility when specifying what data to persist at the client, as compared to using the ViewStateContent property.

When implementing user-defined view state it is up to the developer to set the view state, as well as utilize the view state when a postback occurs.

The Save and Load methods of the Serializer object may optionally be used to set the view state, as well as load the view state when a postback occurs. See the sample code below for an example of this.

For greater simplicity when specifying what chart state to be saved use the ViewStateContent property, which can be set to just data, visual appearance properties or both.

To enable state management set the EnableViewState property to true.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

Copyright © 2001 - 2009 Dundas Data Visualization, Inc. and others.