Fremus.co.za

Demistifying Life and Web Development

jQuery and Microsoft

I susbscribe to The Code Project’s newsletter and today I got some great news, jQuery will be supported in Visual Studio 2008. Now this is some awesome news. Makes one wonder if the Microsoft AJAX library will become redundant.

You can read the full article on Scott Gu’s website.

  • Share/Bookmark
posted by fr3dr1k in AJAX,ASP.NET,Web 2.0,Web Development and have No Comments

Re-usable code for a Gridview and DropdownList

Both the GridView and DropdownList server controls provided in ASP.NET have DataSource and DataBind methods. This means that you could write the same code to populate both controls with data from a database. So first you would create a method for a class like this:

public DataTable GetData()
{
string strSQL = "select * from tblTest";
using(SqlConnection myConn = new SqlConnection(ConfigurationManager.ConnectionStrings["MyDB"].ToString()))
{
    using(SqlCommand myCmd = new SqlCommand(strSQL, myConn))
    {
           myConn.Open();
           using(SqlDataReader myReader = myCmd.ExecuteReader())
           {
                 DataTable myTable = new DataTable();
                 myTable.Load(myTable);
                 myConn.Close();
                 return myTable;
           }
    }
}
}

And then in the codebehind for the page that contains the GridView or DropDownList controls you create a new instance of the class you created above and set the DataSource property for the control. So if you created a class called myClass your code for the Gridview would look like this:

        myTestClass myClass = new myTestClass();
        gvMyGrid.DataSource = myClass.GetData();
        gvMyGrid.DataBind();

The only difference for the DropDownList would be setting the DataTextField and the DataValueField.

  • Share/Bookmark
posted by fr3dr1k in ASP.NET,C#,Web Development,Web Technologies and have No Comments

ASP.NET Navigation and Content Management

At the moment it feels like I am re-designing a navigation system that has probably already been built before. The reason for saying this is because the navigation controls provided to you by Visual Studio 2008 produce table-based layouts, which is not what I want for my website. I want my website to generate valid XHTML and use CSS for layout. So what do I need? I need a navigation system that generates valid CSS and XHTML and that is easy to administer and update without having to meddle in C#, XHTML or CSS code. How do I achieve this goal? Would I have to write my own custom navigation system? It seems so for now. The basic structure of the navigation system would allow for a maximum of three levels of navigation:

  • A top level
  • A second level
  • A third level

The navigation system will at all times make the user aware of where they are in the website, which can be achieved with a breadcrumb navigation system. Each navigation item will display its own associated content. Second level navigation items will have top level navigation item parents and third level navigation items will have second level navigation item parents. The navigation system will also act as a source for creating the site map structure. If a visitor clicks on any item in the top navigation area then content associated with that item will be displayed and the active top level navigation item will show its active. The second level navigation items that are displayed will be associated with the top level item. If a visitor clicks any of the second level navigation items the one that is clicked will become active and content associated with the second level navigation item will be displayed and the second level navigation item that is clicked will show that is active. If the second level navigation item has third level navigation items associated with it then those items will be displayed. If a visitor clicks on the third level navigation item then that item becomes active and content for it will be displayed and that third level item shows that it is active.

The next step is to create an object-oriented design from this structure. Using an object-oriented approach would allow for easy re-use throughout. So lets say we create a class called “section” and give it the following fields:

  • ParentSectionField – This will indicate if there is a parent item
  • SectionField – This will indicate what the current section is
  • SectionHierarchy – This will indicate where in the navigation hierarchy the section item belongs.

The other issue that is a concern for me is content management, and understanding why it is important. Content management is important because it alleviates the need to mess with the code in your website. If your website has a decent content management system you will have a consistent look and feel throughout the website and you will be able to change that look and feel with a few clicks. WordPress is a perfect example of just that. WordPress allows you to easily change themes by uploading it to a directory and by changing it in your admin panel. WordPress is a clear example of design being a layer on top of the underlying function. Content management systems are ideally defined as a layer of functionality or business logic with another layer of presentation logic on top of that. Content management systems are also characterised by its development frameworks. Development frameworks can be seen as large collections of functionality assembled into one component. ASP.NET is an example of a framework technology, because it provides a whole host of features and functionality that you do not have to re-develop to make use of. The ASP.NET Roles and Membership functionality comes to mind, and is not too difficult to implement and administer without having to write much code. The advantage of this is that these features take advantage of the framework features across the whole website. The Roles and Membership feature in ASP.NET is an example of this, because you could easily manage more than one website’s user base from a central administrator control panel. You would not have to re-code the model for each website.

  • Share/Bookmark
posted by fr3dr1k in ASP.NET,Content Management Systems,Web Design,Web Development,Web Technologies,Wordpress and have No Comments

Using SQL Server Authentication

So during the week I had a situation where I had to take an existing web application, that used SQL Server Express, and had to make it work with SQL Server 2005 Standard Edition. Both versions of SQL Server form part of the SQL Server SKU line of products, but their implementation in certain scenarios differ. The providers that are used to connect through your applications are the same though.

I used Visual Studio 2005 to develop the initial application, and in many ways Visual Studio is awesome but in other ways its not, and specifically with regards to SQL Server databases its not that great. Visual Studio allows you to simply drag and drop databases into your web application project, which is great for productivity, but it may cause you some headaches later on. If you have SQL Server Express running on a local machine you will note that a database created in Visual Studio will not show up in SQL Server Management Studio Express. Visual Studio creates the database for you, but it does not attach it to the SQL Server instance that you are running in SQL Server Management Studio Express. SQL Server Express uses a special mode of operation called user instancing, which means it uses accounts such as NETWORK SERVICE and ASPNET to give it rights to connect to the SQL Server Express Instance. SQL Server Express Instancing also adds a 45-75MB memory overhead.

  • Share/Bookmark
posted by fr3dr1k in ASP.NET,SQL Server 2005,Web Development and have No Comments

ASP.NET Authentication

During the week I have been working with SQL Server 2005 Standard Edition and 2005 Express Edition for a website. I have specifically been looking at using SQL Server 2005 for Authentication as opposed to using the standard authentication that comes with ASP.NET when you configure an ASP.NET application in Visual Studio 2005. When you enable authentication for your website an SQL Server Express database (MDF file) is automatically created and the connection string in your web.config file is also changed to point to that SQL Server Express database.

Why is the standard authentication model not appropriate for all uses?

A couple of reasons I can think of:

  1. If you wanted your development environment and your application environment to work together seamlessly then you might want to consider using SQL Server Authentication, or at least get both environments to use connection strings that are similiar or the same.
  2. If you wanted to change or add to the fields provided by the regular membership model provided in ASP.NET and in particular have those fields stored in a proper database table.
  3. If you wanted to use a Database Management System other than SQL Server. Perhaps you want to use MySQL or MS Access. You can also use Active Directory and XML as an authentication model.
  • Share/Bookmark
posted by fr3dr1k in ASP.NET,SQL Server 2005,Web Development,Web Technologies and have No Comments

Reasons to like Silverlight

I have been thinking a bit and there are a few reasons I like Microsoft’s new Silverlight technology.

  1. One reason is that the Silverlight could potentially make the need for Windows Media Player on a host machine obsolete. During the week I removed Windows Media Player from a machine and tested a Silverlight application on it that uses video.
  2. Silverlight is easy to host. You simply add a mime type to IIS. You can find a guide to doing that here.
  3. Silverlight has a Linux implementation called Moonlight.
  4. Integration with Visual Studio 2008. This is an important feature for an web/application developer because your C#/VB.NET skills can be used to develop and enhance Silverlight applications. XAML plays an important role here and bridges the gap between design and development significantly.
  • Share/Bookmark
posted by fr3dr1k in ASP.NET,Silverlight and have No Comments

Sites that use Silverlight

How many sites actually use Silverlight? Silverlight is a Microsoft technology that allows you to create rich and dynamic content for the web. The same Silverlight applications can also be used as desktop applications with WPF (Windows Presentation Foundation). With that in mind I Googled for sites that actually use Silverlight in a live production environment. I already knew of the Hardrock Memorabilia site that uses the Deep Zoom feature. I showed this to some people at work and they were amazed, as was I. So check it out, but be warned you will be required to install a plugin.

So are there other sites that use Silverlight? And if so, what is the quality thereof. I found a site called Nibbles Tutorials which is done entirely with Silverlight. They also have tutorials and samples that you can look at. I found a few more examples on this blog. This site uses Silverlight in a way that allows you to page through books, which is not that new. This site shows a jeep of some kind that you can rotate. Another site allows you to create a valentine’s day card. A museum also used Silverlight and the Deep Zoom effect. Vertigo are the guys who developed the Hardrock Cafe Memorabilia website. They have some Silverlight content as well including a slideshow presentation. Pyramid fashion also use Silverlight.

  • Share/Bookmark
posted by fr3dr1k in ASP.NET,Web Design,Web Development,Web Technologies and have No Comments

Light up the Web – Mix Essentials 2008 Review

I attended the Mix Essentials 2008 event at Canal Walk (Cape Town, South Africa) today and there were quite a few things that interested me. There were five speakers at the event:

  1. David Ives – Developer and Platform Strategy Group for Microsoft in South Africa – Microsoft
  2. Brad Abrams – Group Program Manager for the UI Framework and Services Team – Microsoft
  3. Michael Koester – Designer Marketing Manager for Middle East and Africa and Central and Eastern Europe – Microsoft
  4. Julian Harris – Conchango
  5. David Pugh-Jones – Microsoft

The event was split into two tracks, a developer track and a designer track, but it generally focussed on Silverlight, and more specifically on two software packages, Visual Studio 2008 and Expression Studio, and even more specifically it introduced XAML as a common way for these packages to share content between them. XAML, Extensible Application Markup Language is an XML-like language that defines graphic elements in a human readable form that can be used in vector-imaging programs as well as Visual Studio 2008. This gives designers the flexibility to design interfaces without having to worry about programmers not being able to replicate their designs in a programming environment. Julian Harris demonstrated that you can export files from Adobe Illustrator into XAML format and import that XAML into Visual Studio 2008. XAML is also used in the Expression Studio range of products which includes amongst other two interesting products:

  • Expression Blend
  • Expression Design

Expression Blend is, almost like Adobe’s Flash Studio, which is an IDE that allows you to create WPF (Windows Presentation Foundation) and Silverlight applications. WPF is a technology that allows developers (and designers) to create applications that give users a better user experience (UX). Contemporary windows applications generally use square (often mundane) windows, whereas WPF applications allow designers to implement creative graphics into the interface. Rounded corners and transparent backgrounds for instance are used, and because Expression Blend can read and understand XAML, none of a designer’s creative flair is lost. The developer no longer has any excuses to develop interfaces that do not exactly meet the designer’s design.

  • Share/Bookmark
posted by fr3dr1k in AJAX,ASP.NET,Web 2.0,Web Design,Web Development,Web Technologies and have No Comments

Forums

As a part of the whole Web 2.0 movement forums have proved invaluable, because they allow lots of users to collectively create and share content. Forums differ from blogs and wiki’s, and this is one of the main differences between all three solutions, is the way the information is displayed and handled. Forums use a post-and-reply method. This means that a registered user creates a topic on a forum and writes some content around that topic and then other registered users can comment on that topic. Only registered users can comment on topics, as opposed to blogs and wiki’s which can allow open access to any user.

I read an article recently that listed 8 Popular Open Source Forums, and from the list so far I tested PHPBB on one site and found it to be easy to install. I did find that the Afrikaans language pack was not updated or even available, which is a little disappointing. I then also tried a plugin for WordPress but found the display a little cluttered, and it just felt a little odd to have a forum inside a blog. Next in line is Vanilla, which amazingly is only 386kb when compared to the 2.16Mb of PHPBB. Vanilla took me 5 minutes to install and it is really a very lightweight forum script. You can go take a look here. I cannot run and test YetAnotherForum at this stage because it uses ASP.NET 2.0, but it really looks a bit like Invision’s forum.

  • Share/Bookmark
posted by fr3dr1k in Web 2.0,Web Technologies and have No Comments

Captcha’s and things, life around ASP.NET, and Web 2.0

So what are captcha’s? What’s the purpose of a captcha’s? Captcha’s are those little images that contain a combination of phrases, letters and/or digits. They are used on comment and contact forms on the web to prevent spambots from submitting spam comments. They work because they require human input and someone with eyes that can read the characters on the image. A spambot will not be able to see the image.

I do most of my web development with ASP.NET (C#) because its the environment I find myself in at work and admittedly its an easier environment to develop in than say a Linux or BSD environment. Ease of use in this instance might have a price in terms of hardcore performance but it has a pay-off when it comes to development speed. The server controls that come shipped standard Visual Studio 2005 make it quite easy to have a basic website with basic data controls up and running in a few minutes. The server controls take care of all the processing for you, and all you have to do to use them is drag them onto a form, set a few attributes and voila. Even Visual Web Developer (free download) comes packed with all the tools to get a small data-driven website up and running in no time.

Web 2.0 is a marketer’s catch phrase, I am sure of this. Marketing people might be inclined to use any catch phrase to promote a service or product, if it can draw the customer’s attention. Realistically though they have to realise that Web 2.0 is just a catch phrase, nothing more, in my honest opinion. The technologies that drive Web 2.0 are not so new that they have been re-invented. Social networking forms a part of the whole Web 2.0 theme of which Facebook and MySpace are popular examples. Both of these Social Networking platforms offer an API (Application User Interface) which allow developers to tap into the resources provided by each. The only reason people would want to tap into such a resource is because of the database of users that use that particular network, no other reason. If I developed a Social Networking website and I developed an API for that website and my website had 30 users as opposed to the millions of users that Facebook has, then its obvious to guess where someone might want to invest their time.

  • Share/Bookmark
posted by fr3dr1k in Web Development,Web Technologies and have No Comments
Get Adobe Flash playerPlugin by wpburn.com wordpress themes