4

Our ASP.NET website allows user to perform a variety of queries and displays a network diagram (like a UML diagram) based on the result queried from database. At present, we are generating a Bitmap and displaying it. But since we needed to support a feature to allow user to show/hide certain blocks interactively, we plan to use Silverlight for rendering the graphic. Also we plan to add more interactions in the future.

I have two questions:

  1. Is it possible to an ASP.NET application to 'send' parameters to silverlight application.
  2. Is it possible for a silverlight application to query a SQL server database.

PS. If there are other better alternatives than Silverlight, please do suggest.

softwarematter
  • 28,015
  • 64
  • 169
  • 263

3 Answers3

3
  1. Yes, by using query string parameters in your aspx markup where you define your object tag.
  2. No, at least not directly. You can connect your silverlight application to a WCF application that can query your database.
jrummell
  • 42,637
  • 17
  • 112
  • 171
3

You should use proper layered architecture in general and with SL you cannot, in fact, reference any class library which is not a SL control library.

Once you have your DAL and your BL layers available you can expose part of the logic of the BL as needed with a WCF service layer and use it from SL application. See my suggested layered approach here which works with any UI framework not only with MVC and applies also if you are not using EF in fact.

MVC3 and Entity Framework

Community
  • 1
  • 1
Davide Piras
  • 43,984
  • 10
  • 98
  • 147
2

Simply put: 1 yes, 2 directly: no

Not so simply put:

1:

You can use the Initparams to pass multiple (string) parameters


EDIT: If you put the following in your object code on your aspx page:

<param name="InitParams" value="keyOne=valueOne, keyTwo=valueTwo" />

And in your App.cs you add the following to the constructor:

this.Startup += this.Application_Startup;

Then in that function you can get to the Dictionary of the init params.

private void Application_Startup(object sender, StartupEventArgs e)
{
    foreach (var data in e.InitParams)
    {
        if(data.Key.Equals("keyOne"))
        {
            //data.Value now equals valueOne
        }
    }
}

2: You can use a WCF service to communicate with a server and send and receive data (for example database data)


EDIT:

In this link is explained how to host and consume a WCF service (even hosting in IIS is explained) the consume part works the same for WPF, Silverlight and any other .NET program.


SynerCoder
  • 12,493
  • 4
  • 47
  • 78