views:

253

answers:

2

Hi,

I am working on a project in ASP.NET MVC using C# 3.0.

I am using the Dundas Chart Control for OLAP. As the Dundas control does not directly support MVC it is used on a standard ASP.NET page with a codebehind file. This page is displayed in an iFrame of a normal View returned from a Controller Action.

I have a button in the iFrame which submits a form via Ajax (using jQuery) to a method on the controller. I have also written an extension method for the OlapChart which returns the XML of the current report.

What I am looking for is a way of getting the XML produced by the extension method to the Controller Action which handles the Ajax submit.

I have only developed using ASP.NET MVC so I may be missing something obvious with Code Behind and ASP.NET controls.

Thanks.

A: 

an "uggly" way could be to store the xml in a session or cache that you could access from both controllrs and aspx pages.

cjensen
A: 

I 'solved' this by creating an instance of the controller in the code-behind - in this project using a Spring.net IOC objects.xml file and a Spring.net XmlObjectFactory.

For the button I added an HtmlInputButton to the code-behind and set an onclick event handler. This was made asynchronous using the Dundas OlapManager.GetCallbackEventReference() method combined with a new command handler assigned to the OLAP Chart which provides the calls to invoked the controller methods.

In the Page_Load() function:

OlapClient1.OlapChart.Command += new CommandEventHandler(OlapChart_Command);
            SaveDci.Attributes["onclick"] =
                OlapClient1.OlapManager.GetCallbackEventReference(OlapClient1.OlapChart, "SaveDci", typeof(OlapChart));
            SaveSnapshot.Attributes["onclick"] =
                OlapClient1.OlapManager.GetCallbackEventReference(OlapClient1.OlapChart, "SaveSnapshot", typeof(OlapChart));

And the OLAP command handler:

private void OlapChart_Command(object sender, CommandEventArgs e)
    {
        if (e.CommandName.Equals("SaveDci"))
        {
            // Function to call appropriate controller method
            SaveAsData(sender, e);
        }
        if (e.CommandName.Equals("SaveSnapshot"))
        {
            // Function to call appropriate controller method
            SaveAsSnapshot(sender, e);
        }
    }

The iFrame was updated with a response using jQuery and the OlapMananger.ExecuteClientScript() method:

OlapClient1.OlapManager.ExecuteClientScript("$('#UpdatePanel').text('" + returnMessage + "');");
TonE