European Silverlight 4 & Silverlight 5 Hosting BLOG

BLOG about Silverlight 5 Hosting and Its Techologies - Dedicated to European Windows Hosting Customer

European Silverlight 6 Hosting - HostForLIFE.eu :: Add Silverlight Into a Web Page

clock July 19, 2018 09:24 by author Peter

This article explains how to add Silverlight into a web page using HTML. Use the following procedure to do this.

  • Create a Silverlight application
  • Add some TextBox and button to the XAML file
  • Write the logic on the click event of the button in the .cs file
  • Add a HTML page and add some tags to access the Silverlight generated .xap file

Step 1: Create a new project of Silverlight application named "SilverlightExample".

Uncheck the checkbox to not create a web project for hosting the Silverlight.


Step 2: In the default page named "MainPage.xaml", add 2 Textboxes for getting the input named "txtvalue1" and "txtvalue2" with blank text by default ( text=””) and add a button named "btnAdd" with content "Add". Then create onClick event of the button.
<TextBox Name="txtValue1" Text="" HorizontalAlignment="Left" Height="23" Margin="130,34,0,0" TextWrapping="Wrap"  VerticalAlignment="Top" Width="120"/>
<TextBox Name="txtValue2" Text="" HorizontalAlignment="Left" Height="23" Margin="130,85,0,0" TextWrapping="Wrap"  VerticalAlignment="Top" Width="120"/>
<Button  Name="btnAdd" Content="Add" Click="btnAdd_Click" HorizontalAlignment="Left" Margin="150,154,0,0" VerticalAlignment="Top" Width="75" />

Step 3: Write the code in the section of the onclick event of the button in "MainPage.xaml.cs" that will add the values of the textboxes and show the addition via alert message.
int value1 = Convert.ToInt32(txtValue1.Text);
int value2 = Convert.ToInt32(txtValue2.Text);
int result = value1 + value2;
MessageBox.Show(result.ToString());

Step 4: Now add a HTML Page named "MYPage.html" into the application.

Add an <object> tag to the HTML page with data, type, width and height attributes and <param> element with name and value attributes.
<object data="data:application/x-silverlight-2," type="application/x-silverlight-2"
     width="500" height="500">
    <param name="source" value="Bin/Debug/SilverlightExample.xap" />
</object>

  • data attribute and its value are recommended to avoid performance issues on some browsers.
  • type attribute and the specific value shown are also required. This value uses the Silverlight MIME type to identify the plug-in and the required version.
  • width and height attributes are required for cross-browser compatibility.
  • the <param> element named source is required and indicates the location and name of your application file.

Note: .xap exists in the bin/Debug folder, that's why value="Bin/Debug/SilverlightExample.xap".

Open the HTML file using a browser.

Open the html file via browser
Enter the 2 integer values into the textboxes respectively and press the button to see the ouput.

You can also create the .html file anywhere in your system and put the Silverlight generated .xap file with in the same folder, but in this case you need to write the value="SilverlightExample.xap" because now the .xap and .html files are in the same folder or location.



European Silverlight 6 Hosting - HostForLIFE.eu :: Use Map in Silverlight to show the location

clock July 17, 2018 08:58 by author Peter

Silverlight can support maps in a page to show a particular location. Silverlight provides the Bing map control. To use the bing map you need use two dll files name as Microsoft.Maps.MapControl and another one is Microsoft.Maps.MapControl.Common. Reference of this two dll is must to work with bing map.

By right clicking on the Add Reference on the project name in Solution Explorer, you can add references of these two dlls. 

Once the references are added, you can use the map control as following in your .xaml page:
xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 
xmlns:m="clr-namespace:Microsoft.Maps.MapControl;assembly=Microsoft.Maps.MapControl"

The first mc is for the common map dll and second for the other dll name as MapControl. 

Now, in the Grid control add the map control like below:

<m:Map x:Name="testMapUs" CredentialsProvider="XXXXXXXXXX" ScaleVisibility="Collapsed" LogoVisibility="Collapsed" CopyrightVisibility="Collapsed" Background="White" Mode="Road" Center="" ZoomLevel="12"> 
<m:Pushpin Location="00.00000,-00.00000"/> 
</m:Map>

As shown above

The CredentialProvider is the key which can provide the credential to use the map that you can get it form this website.

http://www.bing.com/mapindia/?mkt=en-in

Also from this website, you will get the actual location that you want to show in your map control.

<m:Pushpin/> tag can show the pushpin location on your map so user can get the exact location directly.

You will also get an longitude of your location from the above site. As per shown above when you use this control it show Logo, Copyright text and scale on  the map. If you do not need to display these, you can remove it by setting its Visibility property to Collapsed. 

There is different modes in the map like Road and Aerial. To change the mode of the map there is one property name as Mode="Aerial". In both mode aerial and road, you can have possible to set the zoom level as per your requirement.


European Silverlight 6 Hosting - HostForLIFE.eu :: Spire For WPF, .NET And Silverlight Applications From E-ICEBLUE

clock July 12, 2018 08:35 by author Peter

This article is about my views on Spire.doc which I tried for development purposes on my personal site. Now, I would like to discuss a few points about it. Recently, I came across a tool for .NET developers named Spire, which has more features and is an easy GUI interface tool for clients. E-ICEBLUE has a large number of tools and helps developers  a lot with different streams like .NET, Windows Presentation Foundation, and Silverlight. E-ICEBLUE also helps in providing customer support towards all products for their clients.

Tools from E-ICEBLUE

For .NET

  • Office for .NET
  • OfficeViewer for .NET
  • Doc for .NET
  • DocViewer for .NET
  • XLS for .NET
  • Spreadsheet for .NET
  • Presentation for .NET
  • PDF for .NET
  • PDFViewer for .NET
  • PDFViewer for ASP.NET
  • DataExport for .NET

For WPF

  • Office for WPF
  • Doc for WPF
  • DocViewer for WPF
  • XLS for WPF
  • PDF for WPF
  • PDFViewer for WPF

For Silverlight

  • Office for Silverlight
  • Doc for Silverlight
  • XLS for Silverlight
  • PDF for Silverlight

I tried using Spire.Office for my developments on .NET and WPF.

  • Helps in opening all the file formats.
  • Develop your .NET applications with easy GUI.
  • Surf for your APIs with the help of the "HELP document" available with the software.
  • Helps in opening Word documents, Spreadsheets, PDFs, and your project files on .NET applications including WPF, ASP.NET, WinForms, Web Services, etc.
  • You have all options here which you can find in MS-Office, like find & replace, copy/paste, review your documents, working with extensions, etc.
  • Helps in the conversion of various file formats – Excel sheets – adding digital signatures, etc.

I tried working with WPF projects with Data Binding, Animations, MVVM model, developing a media player, isolated storage, etc., and I feel Spire helps us with all features that Microsoft Visual Studio has in it.

Still, Spire works in a large scale on conversion of file formats, merging the data, exporting the data, accessing all data file formats, and multiple printing orientations etc.



European Silverlight 6 Hosting - HostForLIFE.eu :: Update Data Using Silverlight RIA Enabled ServiceToday

clock July 10, 2018 11:28 by author Peter

Update Data Using Silverlight RIA Enabled ServiceToday, in this article let's play around with one of the interesting and most useful concepts in Silverlight.

Question: What is update data using Silverlight RIA enabled service?
In simple terms "This application enables to update the data in the database with help of Silverlight RIA enabled service. It uses base platform of entity framework to communicate with database".

Step 1: Create a database named "Company" with employee table in it.

Step 2: Open up Visual Studio and create a new Silverlight application enabled with RIA Services
Step 3: When the project is created. Right-click on RIA Service project and add new entity data model framework and set it up for previously created database.
Step 4: Again right click on RIA service project and add Domain Service Class as new item.
Step 5: Complete code of EmployeeDomain.cs looks like this (Domain Service Class)
namespace SilverlightRIAInsert.Web
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Linq;
using System.ServiceModel.DomainServices.EntityFramework;
using System.ServiceModel.DomainServices.Hosting;
using System.ServiceModel.DomainServices.Server;
// Implements application logic using the CompanyEntities context.
// TODO: Add your application logic to these methods or in additional methods.
// TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
// Also consider adding roles to restrict access as appropriate.
// [RequiresAuthentication][EnableClientAccess()]
public class EmployeeDomain : LinqToEntitiesDomainService<CompanyEntities>
{
    // TODO:// Consider constraining the results of your query method.  If you need additional input you can
    // add parameters to this method or create additional query methods with different names.
    // To support paging you will need to add ordering to the 'Employee'
    query.public IQueryable<Employee> GetEmployee()
    {
        return this.ObjectContext.Employee;
    }
    public void InsertEmployee(Employee employee)
    {
        if ((employee.EntityState != EntityState.Detached))
        {
            this.ObjectContext.ObjectStateManager.ChangeObjectState(employee, EntityState.Added);
        }
        else{this.ObjectContext.Employee.AddObject(employee);
        }
    }
    public void UpdateEmployee(Employee currentEmployee)
    {
        this.ObjectContext.Employee.AttachAsModified(currentEmployee, this.ChangeSet.GetOriginal(currentEmployee));
    }
    public void DeleteEmployee(Employee employee)
    {
        if ((employee.EntityState != EntityState.Detached))
        {
            this.ObjectContext.ObjectStateManager.ChangeObjectState(employee, EntityState.Deleted);
        }
        else{this.ObjectContext.Employee.Attach(employee);
           this.ObjectContext.Employee.DeleteObject(employee);
        }
    }
}
}


Step 6: Now rebuild the solution file.
Step 7: The complete code of MainPage.xaml looks like this:
<usercontrolx:class="SilverlightRIAInsert.MainPage"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"mc:ignorable="d"
d:designheight="300"d:designwidth="543">
<Gridx:Name="LayoutRoot"Width="608">
<TextBlockHeight="23"HorizontalAlignment="Left"Margin="152,29,0,0"Name="textBlock1"Text="Id"FontFamily="Verdana"FontSize="15"VerticalAlignment="Top"/>
<TextBoxHeight="23"HorizontalAlignment="Left"Margin="252,25,0,0"Name="textBox1"VerticalAlignment="Top"Width="120"/>
<TextBlockHeight="23"HorizontalAlignment="Left"Margin="150,72,0,0"Name="textBlock2"Text="FirstName"FontFamily="Verdana"FontSize="15"VerticalAlignment="Top"/>
<TextBoxHeight="23"HorizontalAlignment="Left"Margin="252,68,0,0"Name="textBox2"VerticalAlignment="Top"Width="120"/>
<TextBlockHeight="23"HorizontalAlignment="Left"Margin="150,113,0,0"Name="textBlock3"Text="LastName"FontFamily="Verdana"FontSize="15"VerticalAlignment="Top"/>
<TextBoxHeight="23"HorizontalAlignment="Left"Margin="252,113,0,0"Name="textBox3"VerticalAlignment="Top"Width="120"/>
<ButtonContent="Update"FontFamily="Verdana"FontSize="19"Background="DeepSkyBlue"Height="44"HorizontalAlignment="Left"Margin="252,206,0,0"Name="button1"VerticalAlignment="Top"Width="120"Click="button1_Click"/>
<TextBoxHeight="23"HorizontalAlignment="Left"Margin="252,155,0,0"Name="textBox4"VerticalAlignment="Top"Width="120"/>
<TextBlockHeight="23"HorizontalAlignment="Left"Margin="152,155,0,0"Name="textBlock4"Text="Age"FontFamily="Verdana"FontSize="16"VerticalAlignment="Top"/>
</Grid>"
</usercontrol>


Step 8: The complete code of MainPage.xaml.cs looks like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.ServiceModel.DomainServices.Client;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using SilverlightRIAUpdate.Web;
namespace SilverlightRIAUpdate
{
public partial class MainPage : UserControl
{
    public MainPage()
    {
        InitializeComponent();
    }
    EmployeeDomain objDomain = new EmployeeDomain();
    private void button1_Click(object sender, RoutedEventArgs e)
    {
        EntityQuery<Employee> query = objDomain.GetEmployeeQuery();
        objDomain.Load(query, UpdateLoad, null);
        MessageBox.Show("Data Updated Successfully");
    }
    public void UpdateLoad(LoadOperation<Employee> emp)
    {
        foreach (Employee e in objDomain.Employees)
        {
            if (e.Id == int.Parse(textBox1.Text))
           {
                e.FirstName = textBox2.Text;
                e.LastName = textBox3.Text;
                e.Age = int.Parse(textBox4.Text);
                objDomain.SubmitChanges();
                break;
            }
        }
    }
}
}

 



About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.


Tag cloud

Sign in