<![CDATA[Dundas Support Zone - Pass dashboard parameters from viewer to a web application]]>http://support.dundas.com/Dashboard5.Pass_dashboard_parameters_to_web_application.ashxWed, 17 Jun 2020 16:41:52 GMTScrewTurn Wiki RSS Feed Generator<![CDATA[Pass dashboard parameters from viewer to a web application]]>http://support.dundas.com/Dashboard5.Pass_dashboard_parameters_to_web_application.ashx


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.


  • 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

nikhilb@dundas.com (nikhilb@dundas.com)Thu, 12 Jun 2014 13:57:39 GMTF02BDA733A955A4339F721290DD2A7ED