Running Crystal Reports from Silverlight

I provide a short WebCast supplementing this blog - HERENote: It appears I was having some audio difficulty in the early part of the webcast showing how to navigate to the HTML BROWSER INTEGRATION webcast - since I provide the link below I published the webcast as is.

The following www.Silverlight.net webcast HTML BROWSER INTEGRATION provides the key to running Crystal Reports from Silverlight.  Once you complete the webcast you'll find it takes only a few steps to get your Crystal Reports up and running.

I downloaded the C# Source code from the above referenced link, added the following class (MyClass) to the HtmlInteraction_CS project's Page.xaml.cs file and updated the Button1_Click() to support it:

/// <summary>

/// Added Inner class for proof of concept

/// </summary>

public class MyClass

{

    public string ReportName { get; set; }

    public int ID { get; set; }

 

    /// <summary>

    /// Override ToString so we can easily return our

    /// URL Parameters

    /// </summary>

    /// <returns></returns>

    public override string ToString()

    {

        return string.Format("?ID={0}&Name={1}", ID, ReportName);

    }

}

 

/// <summary>

///

/// </summary>

/// <param name="sender"></param>

/// <param name="e"></param>

private void Button1_Click(object sender, RoutedEventArgs e)

{

    // Instantiate class setting ReportName to textbox value

    MyClass para = new MyClass

    {

        ID = 10,

        ReportName = TextBox1.Text

    };

    // Invoke the sayGoodbye javascript method

    HtmlPage.Window.Invoke("sayGoodbye",

        new string[] {para.ToString()});

}

 

With my Silverlight code completed I only needed to prepare the Website code.  I renamed the testpage to CrystalReportPrototype.aspx and added the window.open("Report.aspx"+fname, "_blank") to the sayGoodbye(fname) javascript method as shown below:

 

So all that remained was to create my Report.aspx and reports.  I dropped a CrystalReportViewer object on the page and named it Demo1.  I then parse out the "Name" and run the applicable report, i.e., DemoReport (default), DemoReport1 and DemoReport2.

After I saw all was well I used Expression Blend to spiffy up the Silverlight screen (took all of five minutes):

 

SL-HtmlInteraction.zip (1.68 mb)  <= SOURCE CODE


Tags: , ,
Categories:


Actions: E-mail | Permalink |  Grammar/Typo/Better way? Please let me know