Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

Chart.GetFromCache Method

Retrieves the specified chart from the cache.

Namespace:  System.Web.Helpers
Assembly:  System.Web.Helpers (in System.Web.Helpers.dll)
public static Chart GetFromCache(
	string key
)

Parameters

key
Type: System.String
The ID of the cache item that contains the chart to retrieve. The key is set when you call the SaveToCache method.

Return Value

Type: System.Web.Helpers.Chart
The chart.

The following example shows how to retrieve the chart from the cache by using the GetFromCache method.


@{ 
    var chartKey = Request["key"]; 
    if (chartKey != null) { 
        var cachedChart = Chart.GetFromCache(key: chartKey); 
        if (cachedChart == null) { 
            cachedChart = new Chart(600, 400); 
            cachedChart.AddTitle("Cached Chart -- Cached at " + DateTime.Now); 
            cachedChart.AddSeries( 
               name: "Employee", 
               axisLabel: "Name", 
               xValue: new[] { "Peter", "Andrew", "Julie", "Mary", "Dave" }, 
               yValues: new[] { "2", "6", "4", "5", "3" }); 
            cachedChart.SaveToCache(key: chartKey,  
               minutesToCache: 2,  
               slidingExpiration: false); 
        } 
        Chart.WriteFromCache(chartKey); 
    } 
}


  • Medium trust for the immediate caller. This member can be used by partially trusted code.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.