416.467.9100 | Dundas Data Visualization | Login
Welcome Guest
Dashboard v5.0

This site makes extensive use of JavaScript.

Please enable JavaScript in your web browser and reload the page before proceeding.

Pass dashboard parameters from viewer to a web application

Hide navigation
RSS
Modified on Thu, 12 Jun 2014 09:57 AM Categorized as Level-Expert, Parameter Controls, Parameters, Samples, Viewer

Overview

This article shows how to retrieve and pass parameters from the embedded Dashboard Viewer to an ASP.NET web application by saving the parameters, per dashboard, per user while browsing.

Steps involve a function in the web page that takes a string and posts it it to the .aspx page using an AJAX call. This JavaScript function is called in the dashboard application using the services.EvalJavaScript at every parameter changed event. This call passes all the parameter values on the dashboard to the function on the webpage. The values can then be retrieved and stored in session using the Request and Session objects in the web application.

Once the parameters are retrieved, all the user choices can be remembered if they navigate away from the page and come back for as long as the sessions lasts. This is done using the sample on how to send parameters from ASP.NET application to a Dashboard.

Apart from saving the values to session, they can also be stored more permanently, by user name, so that it always remembers what the user was last looking at on any particular dashboard.

Steps

  • Add this code to the page hosting the Dashboard viewer. This takes in a string and posts it to the .aspx page using AJAX.

function sendParameters(parameterList) { request = new XMLHttpRequest(); request.open('POST', 'SaveParameters.aspx', true); request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); request.setRequestHeader("Connection", "close"); request.send('params=' + parameterList); }

  • Call the above JavaScript function in the dashboard application by running a Dashboard script like this at every parameter changed event using the services.EvalJavaScript. This call collects all the parameter values on the dashboard and passes them to the function on the webpage.:

string test = "dashboardId," + services.CurrentDashboard.DashboardId.ToString(); foreach (DashboardParameter p in services.CurrentDashboard.DashboardParameters) { test += "," + p.Name + "," + p.FilterValues0.MemberValues0.Values0.ToString(); } services.EvalJavaScript("sendParameters('" + test + "');");

  • Retrieve and store the values in session using the Request and Session objects in the web application:

if (Request"params" != null) { String dashboardParametersInput = Request"params"; String" title=" dashboardParameters = dashboardParametersInput.Split(new char">"> dashboardParameters = dashboardParametersInput.Split(new char[ { ',' }); Session"dashboardParameters" = dashboardParameters; }

if (Session"dashboardParameters" != null) { String">"> dashboardParameters = (String)Session["dashboardParameters"; for (int i = 0; i < dashboardParameters.Length; i += 2) { Response.Write(dashboardParametersi + ": " + dashboardParametersi + 1); Response.Write("
"); } }


Another way to store the parameters is to use the serializing and deserializing methods in the ParameterInfoCollection that works in both client (Silverlight and DundasScript) and server (.NET).



/***** Serialize *****/ ParameterInfoCollection parameters = new ParameterInfoCollection(); // Add parameters string parametersString = parameters.SerializeToString();

/***** Deserialize *****/ ParameterInfoCollection parameters = ParameterInfoCollection.Parse(parametersString);



Related Topics

About Dundas | Contact Us Follow us on Twitter! | Privacy Statement | Report Site Issues

Copyright © 2009-2014 Dundas Data Visualization, Inc.