Thursday, February 28, 2008

Creating a Silverlight-AJAX-Enabled Web Site with Silverlight 1.1 and VS.NET 2008

Install the necessary components.

  1. Install the Windows Silverlight 1.1 Runtime from here: http://www.microsoft.com/silverlight/resources/LicenseWinDev.aspx
  2. Install the Microsoft Silverlight 1.1 Tools Alpha for Visual Studio 2008 from here: http://www.microsoft.com/downloads/details.aspx?familyid=25144c27-6514-4ad4-8bcb-e2e051416e03&displaylang=en
  3. Install VS.NET 2008.

Create an ASP.NET Web Application

  1. Startup VS.NET 2008.
  2. Click on File->New->Web Site.
  3. Select ASP.NET Web Site.
  4. In the Location path, replace "WebSite1" with "DotNetFun" (without quotes).
  5. Click on OK.
  6. Press Ctrl-Shift-S to save all of your changes.

Add Silverlight Content to an ASP.NET Web Site

  1. In VS.NET 2008, the ASP.NET Web Site created in the preceding steps,
  2. In the Solution Explorer, right-click on the 'DotNetFun solution and click on Add->New Project.
  3. Under project types, select/click on Silverlight
  4. Under templates, select/click on Silverlight Project.
  5. Change the project name from "SilverlightProject1" to "SilverlightProjectTest" (without quotes).
  6. Click on OK.
  7. In the Solution Explorer, right-click on the DotNetFun ASP.NET project and click on Add Silverlight Link.
  8. Select/click on the SilverlightProjectTest project.
  9. Click on OK.
  10. Click on Yes to enable Silverlight script debugging.
  11. Press Ctrl-Shift-S to save all your changes.

Adding AJAX Functionality to an ASP.NET Web Site

  1. Simply add an AJAX Web Form to the ASP.NET project.
  2. Press Ctrl-Shift-S to save all your changes.

Discussion

Wednesday, February 27, 2008

Getting Started with Silverlight 1.1 and Visual Studio .Net 2008

Install the necessary components.

  1. Install the Windows Silverlight 1.1 Runtime from here: http://www.microsoft.com/silverlight/resources/LicenseWinDev.aspx
  2. Install the Microsoft Silverlight 1.1 Tools Alpha for Visual Studio 2008 from here: http://www.microsoft.com/downloads/details.aspx?familyid=25144c27-6514-4ad4-8bcb-e2e051416e03&displaylang=en
  3. Install VS.NET 2008.

Create a Silverlight VS.NET 2008 project.

  1. Startup VS.NET 2008.
  2. Click on File->New->Project.
  3. Under Visual C#, click on the Silverlight node.
  4. Select the Silverlight Project project.
  5. Click on OK.
  6. Double click on the Page.xaml XAML file in the Solution Explorer.
  7. Between the Canvas XML elements, type in the following XAML code: <TextBlock x:Name="txtHelloWorld" MouseLeftButtonDown="txtHelloWorld_Click"> Hello World! Click here.</TextBlock>
  8. Double click the Page.xaml.cs file in the Solution Explorer.
  9. Add the following event handler method: <TextBlock x:Name="txtHelloWorld" MouseLeftButtonDown="txtHelloWorld_Click"> Hello World! Click here.</TextBlock>
  10. Save all changes.
  11. Test the Silverlight application by right-clicking on the TestPage.html file in the Solution Explorer and clicking on View in Browser, then click on the text--it should respond to the event.

Discussion

The JavaScript code in the TestPage.Html.js file is responsible for actually rendering the Silverlight content in the client's browser. This is done by calling the createSilverlight() JavaScript function from within the TestPage.Html page. The JavaScript code in the Silverlight.js file checks if Silverlight is installed and redirects the user to install if chosen to do so.

Please note that this Silverlight project does not incorporate ASP.NET functionality/content, only basic HTML content. In order to create an ASP.NET website that makes use of Silverlight functionality, please refer to my article titled "Creating a Silverlight-AJAX-Enabled Web Site with Silverlight 1.1 and VS.NET 2008".

Saturday, February 16, 2008

MS Visual Studio 2008 - New Features - System Designer

Visually Create Systems with VS.NET 2008 Architecture Edition

The new System Designer project (found in the New Project\Distributed Systems folder) allows developers and architects to, first, visually define and design an application system. Prior to System Designer, you only had the Application Design project, an application-scope-only designer, limiting you to defining and implementing applications, such ASP.NET, Windows Forms, Web Services, etc., in a visual way. The problem with the Application Design project, of course, is that it's application-scope-limited--it pertains to an application, or set of related applications, and not to an entire system or even a multitude of systems. Conceptually speaking, a system should comprise one or more applications/services, without having to define applications within an application project per se. The System Design project allows us to create systems and add to them inter-related applications and even sub-systems--a beneficial feature for us application designers and system architects.

The System Design project helps to facilitate visual system-design and implementation in VS.NET 2008 Architecture edition. To develop a System Design project, perform the test steps below:

  1. Startup VS.NET 2008 Architecture Edition.
  2. Click on File, New, then Project, or press Ctrl-Shift-N.
  3. Locate and select the Distributed Systems folder/node.
  4. Select System Design, then click on OK.


    You are now presented with two files/objects: a System diagram (*.sd) and an Application diagram (*.ad).
  5. Open up the Toolbox (or press Ctrl-Alt-X). You'll see a list of System Design and Application Design specific controls.
  6. This test system will consist of an ASP.NET Web Site, ASP.NET Web Service, and External Database, so drag and drop these application design types from the Toolbox onto the System Design (.sd) designer area.


    Adding applications to the System Designer area will result in those applications also being added to the Application Design (.ad) area.
  7. Select WebApplication1, then click on the Diagram menu, then on Rename.
  8. Name it ASPNETApplication, then click on OK.
  9. Select WebApplication2, then click on the Diagram menu, then on Rename.
  10. Name it ASPNETWebService, then click on OK.
  11. Select Database1, then click on the Diagram menu, then on Rename.
  12. Name it SQLServer2005, then click on OK.
  13. When you drag and drop applications onto the design area, default endpoints are automatically generated for each one. To ensure our system allows reusability via the ASP.NET Web Service (i.e., not only can the ASP.NET application leverage the web service, but so can a potential many other applications and services), the ASP.NET application will use this web service for all business logic and data tier services/functionality, so to define such a relationship logically and visually, we need to connect the applications/services accordingly. Endpoints are the means by which applications and services inter-communicate, so connections between them must be setup.
  14. We need to delete the useless Web Content Endpoint for the ASPNETApplication web application, so select the WebContent1 endpoint, then press Delete.
  15. Since the ASPNETApplication application will be consuming the ASPNETWebService web service, we need to create a Web Service Consumer Endpoint on it. This endpoint is created automatically when a connection is made between the ASPNETApplication application and the ASPNETWebService web service. Right-click on the ASPNETApplication application, then click on Connect.
  16. In the Connect To area, ensure that the Application is ASPNETWebService and that the endpoint is WebService1.
  17. Click on OK.
  18. Now let's connect the ASPNETWebService to SQLServer2005 database. Right-click on the ASPNETWebService web service application, then click on Connect.
  19. Ensure that the Connect To Member is SQLServer2005 and that the Connect To Endpoint is SQLServer2005.
  20. Click on OK.
  21. In the Choose Data Source dialog box, in the Data Source drop-down list, select Microsoft SQL Server, then click on Continue.
  22. In the Connection Properties dialog box, specify all relevant SQL Server information. This is the SQL Server that the ASPNETWebService web service will connect it.
  23. Click on OK. The endpoint connections should now look like the following:

Tuesday, February 05, 2008

T-SQL 2005: Encrypting & Decrypting Data

-- Tested and compatible with SQL Server 2005 -- Encrypting a column using symmetric encryption: -- Check for a DB Master Key; it has an ID of 101; if not, create it: IF NOT EXISTS(select * from sys.symmetric_keys where symmetric_key_id = 101) CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'SDF*(U$IOJ$#U*(FEIDO'; -- Create a certificate used to encrypt the key: IF NOT EXISTS(SELECT * FROM sys.certificates WHERE name = 'TestCert') CREATE CERTIFICATE TestCert WITH SUBJECT = 'Test Certificate'; -- Create a key: IF NOT EXISTS(select * from sys.symmetric_keys where name = 'TestKey') CREATE SYMMETRIC KEY TestKey WITH ALGORITHM = DES ENCRYPTION BY CERTIFICATE TestCert; -- Open the symmetric key: OPEN SYMMETRIC KEY TestKey DECRYPTION BY CERTIFICATE TestCert; -- Encrypt data DECLARE @EncryptedData VARBINARY(255), @DecryptedData VARCHAR(255); SET @EncryptedData = EncryptByKey(Key_GUID('TestKey'), 'My encypted data!'); SELECT @EncryptedData AS EncryptedData; -- Decrypt encrypted data: SELECT CAST(DecryptByKey(@EncryptedData) AS VARCHAR) AS DecryptedData;

MySpace to Launch Developer Site

It's about time, too, as FaceBook has given developers the ability to create FaceBook applications for some time now. I can just imagine, though, what security issues will arise from spyware- and spam-developers.

TO get there, go to developer.myspace.com.

Here's the article:

Juan Carlos Perez, IDG News Service

MySpace will open the doors of its developer Web site on Tuesday and make available there the necessary tools to build applications for the world's most popular social-networking site.

Developers will have about one month to familiarize themselves with the development tools and create and test applications before MySpace begins letting its members install them early in March.

"Developers will be able to build applications, but they'll be in the sandbox environment where consumers won't be able to see them," said Kyle Brinkman, vice president and general manager of Platform for MySpace.

With the opening of the developer Web site, MySpace gets closer to catching up to its main rival, Facebook, which opened its platform to external developers in May.

For Facebook, despite some bumps along the way, opening its platform has been overwhelmingly positive. More than 14,000 applications have been created for the site, which in turn has increased its attractiveness to current and potential members.

MySpace isn't alone in following Facebook's lead, as most major social-networking site operators have decided to open their platforms to external developers as well.

In addition to the individual developer platforms, Google unveiled in November its OpenSocial project, which aims to provide a set of common APIs (application programming interfaces) for social-networking operators to adopt, so that applications built with those APIs will work across multiple sites.

To make sure that the applications are safe to use, MySpace will test all of them before making them available to its members, Brinkman said.

Developers will be able to generate revenue from their applications by placing advertising on their applications' "canvas" pages, where members manage the applications they install. Developers will get to keep 100 percent of the advertising revenue generated on canvas pages, Brinkman said.

Developers can choose to run ads from third-party ad providers as long as the ads conform to MySpace policies, such as not containing pornographic content. Moreover, MySpace will let developers run ads from two new ad services that it is beta testing and that it plans to launch at a later date called HyperTargeting and SelfServe, Brinkman said.

In addition to the canvas page, applications will also be featured on their own profile pages, where developers will be able to explain in detail what each application does and how it works. Moreover, there will be a gallery where the applications will be listed. Of course, the applications will also appear on the profiles of members who install them and on members' MySpace home pages.

MySpace will make available three types of APIs to developers: Google's OpenSocial APIs with MySpace extensions for building applications in JavaScript and HTML; ActionScript to build Flash applications; and Representational State Transfer (REST) APIs for applications that require server-to-server connections.

Applications will be able to make use of data on MySpace profiles, but they will be governed by existing privacy controls that apply to members.

The MySpace Developer Platform site will also include documentation, sample code and discussion forums.

Also on Tuesday, MySpace will launch a blog geared toward developers, where MySpace staffers will post relevant information and news about the program.