Tuesday, August 09, 2011

Passing parameters to a Silverlight application

In this beginners post, I will describe three different ways to pass parameters to a Silverlight application.

Method 1 - Add parameters to the URL.
Method 2 - Use InitParams (inside the Silverlight control host).
Method 3 - Read a file containing the parameters.

I've created a solution containing all three. If a parameter exists on two or more methods the priority is File/URL/InitParams. The parameters are x1,y1,x2,y2 - these are the coordinates of the desired map extent. First we check if exist in the URL. If not, we move to the InitParams, In the end we load the city txt file.

examples:
http://www.galsystems.com/files/sample16.passing.parameters/sldemoTestPage.html
Here there are none in the file and URL, so the InitParams takes (Sau Paulo).

http://www.galsystems.com/files/sample16.passing.parameters/sldemoTestPage.html?x1=-13623000&y1=6039000&x2=-13612000&y2=6046000
Here there are in the InitParams and URL. URL wins (Seattle).

http://www.galsystems.com/files/sample16.passing.parameters/sldemoTestPage.html?city=london
http://www.galsystems.com/files/sample16.passing.parameters/sldemoTestPage.html?city=chicago
http://www.galsystems.com/files/sample16.passing.parameters/sldemoTestPage.html?city=wellington
Here the URL city takes any parameter in the URL(x1,x2,y1,y2) or InitParams.

sldemoTestPage.html:


 
 
 
 
 
   
 http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.50826.0" style="text-decoration:none">
   Get Microsoft Silverlight
 


Read more: Oren Gal GIS Blog
QR: passing-parameters-to-silverlight.html

Posted via email from Jasper-Net