21/2/10

Developing Silverlight 3.0 Web Applications

    Developing a Silverlight Web application is a great experience. To get started all you need is Visual Studio 2008 with Service Pack 1 installed, Silverlight 3.0 SDK, Silverlight toolkit and Expression Blend 3.0. Expression Blend is needed since Visual Studio 2008 does not have a designer so you will not be able to drag and drop controls like you do in aspx pages. Blend will give you an easy solution to apply positioning etc on your controls, unless you want to do it by configuring the XAML file!!! Anyway Visual Studio 2010 release will have a designer so just be patient...

Download the tools at http://silverlight.net/getstarted/

   Building your first Silverlight Web Application will not be difficult if you are already familiar with XML, since everything that has to do with designing and configuring your pages is done by writing on a XAML file.

If you are unfamiliar with XAML visit http://msdn.microsoft.com/en-us/library/ms752059.aspx

   Building the back bone of a Silverlight Web Application, Visual Studio 2008 gives you the option to create a stand alone Silverlight Application or a solution that contains a Silverlight Application project and a project with the nessecary aspx pages in order to test your application.

   When deploying a Silverlight Web Application keep in mind that not everyone has Silverlight installed on their machines. This means that the end user will be prompted by default to install Silverlight in order to proceed. But not every user is "Computer Friendly", meaning that my father for example will hesitate to install the new technology fearing that Silverlight might be a virus or that malicious code will destroy his computer.

   Quoting a tip in Matthew MacDonald's Pro Silverlight 3 in C#
Studies show that Web Surfers are far more likely to make it through an installation process on the Web if they are guided to do it as a part of an application, rather than prompted to install it as a technology...
  This means that users might be suspicious of the Silverlight logo, small banner and the Get Silverlight button that appears on their screen of they do not have Silvelight and try to view your page. To give web surfers a friendlier experience try to customize that content and make it part of your Web Application

  A final issue is that of the versioning. Silverlight 4 Beta is already out there. So what will happen if I have Silverlight 3 and try to view a site on Silverlight 4???Again Silverlight will show a dialog box prompting for upgrades etc something that a non "Computer Friendly" person might be suspicious of. The suggestion is to make the upgrade part of your Web Application by customizing its behavior when the version problem occurs.

More on Silverlight about to come...

7/2/10

How to create a web custom control

   The way I went about it was to add a class library to my Web Application. After that I made my class eg customGrid inherit from GridView. On the Solution Configuration I changed the setting from Debug to Release in order to get the DLL from the release folder and add the newly built control to my toolbox...

   I dragged and dropped the control on my Default.aspx and went on to built the whole prject on debug mode. That's when I got the Warning
Warning    1    Generation of designer file failed: Unknown server tag 'cc1:customGrid1'.    C:\Users\MSen\Documents\Visual Studio 2008\Projects\myGridTest2\myGridTest2\Default.aspx    16    0    myGridTest2
This warning makes one unable to access the properties and methods of the new control, trying to set its DataSourse for example, since the Default.aspx.designer.cs does not contain code for our control. Thus the way to go around this warning and become able to access the members of the control is to modify the Default.aspx.designer.cs by including the highlighted code

    public partial class _Default {
       
        /// <summary>
        /// form1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlForm form1;
        protected global::customControlNamespace.CustomControlName CustomControlID;
    }
 The afore mentioned work around will make you able to access te members of the control, but the warning will still appear every time you built the project


Another way to go around it is to open IIS and
1) Go to 'Default Web Site' properties.
2) At 'Web Site' Tab click on 'Advanced..' button.
3) In 'Multiple identities for this site' list select '80:localhost' row and then click 'Edit' button.
4) Erase the 'localhost' string there and click ok.
5) Now close your solution in Visual Studio and open it again.
If IIS is not visible try
Opening Control Panel, Programs & Features, Turn Windows Features on or off, Internet Information Services and choose the IIS Management Console