Archive for November, 2008
On that Session-less shopping cart issue
Posted by fr3dr1k | Filed under ASP.NET, Web Development, Web Technologies
In my post yesterday I mentioned that I would like to develop a session-less shopping cart through the use of web services and classes. Well, I changed my mind a bit because I am not sure if AJAX can maintain state. Can it? How will AJAX retain state? I’m not sure yet, so sessions it is.
There are some important reading bits that need to be covered before you can get stuck into sessions, and its always better to try and understand something as far as possible before you simply jump in and implement it. The first article that proves invaluable (and very important) is the ASP.NET Page Lifecycle where after I can recommend you read the State Management Overview Article to understand the difference between Client side and Server side state management and what each offers. Why is state management such an issue? Well firstly because HTTP is stateless, after you make a request to a web server for a web page there is no further communication between you and that server. So to create a state, you use a state management technique, which can either be client or server side. With either technique you have several options and each option has some advantages and disadvantages.
My fear with session state management was the performance hit my server might take, but I have not really tested it enough to make that assertion.
Unobtrusive JavaScript and a Session-less shopping cart
Posted by fr3dr1k | Filed under AJAX, ASP.NET
What is the idea behind unobtrusive JavaScript? What makes JavaScript unobtrusive? Does it mean removing any onlclick events in your markup and handling those click events with an approach as provided with jQuery? With jQuery its very (extremely) easy to traverse between DOM elements and its even easier associating events to elements and executing them.
I havent been doing a lot of JavaScript recently but you cannot really avoid it, but you can also not build an entire website with JavaScript and HTTPRequests alone (not search engine friendly), but you can also not rely entirely on server side code to do all the magic for you.
The other issue that has been bugging me of late is the idea of creating a session-less shopping basket, a shopping basket that uses a combination of web services and traditional classes. Within the .NET environment the only reason you might need to use sessions is to store DataTables or DataSets, but the question is how expensive is that on server resources. Would I be able to create the same session-based application with web services and traditional classes? After all you are adding web references to your web applications, and those web references all contain class declarations.
Economic Meltdown
Posted by fr3dr1k | Filed under General
The economic meltdown seems to be hitting South Africa as well. If you think about the trouble General Motors are going through in the USA and how that trouble will spill over to South Africa. I wonder how that impacts web developers or IT professionals?
ASP.NET, handlers and IHTTPHandler
Posted by fr3dr1k | Filed under ASP.NET, C#
I have never used handlers (.ashx) files in any of my .NET web development projects, but this all changed in the last two days. The way I understand a handler is that it acts as a ‘process’ handler and does not write any output to the browser. Where would you use this? Well I used it for a shopping cart (but in hindsight I will change this) by using a handler to process the items added to the cart. The handler took a querystring and created a datatable of none existed or added the data to a datatable if that datatable already existed and stored the datatable in a session variable, which could then be accessed throughout the application. Accessing querystring variables in a handler file requires that you implement the IHTTPHandler interface, i.e. you cannot simply type Request.Querystring in the handler.
Panel and its DefaultButton property
Posted by fr3dr1k | Filed under ASP.NET, C#
ASP.NET has a server control called a panel, which allows you to display other server controls or HTML elements inside it, and one of its properties is DefaultButton. By setting the DefaultButton to the ID of a button within the panel you basically set its default keyboard event that will fire the click event associated with that button. The other alternative to this would be to add the property to the TextBox in your CodeBehind.
Understanding namespaces in C# and .NET
Posted by fr3dr1k | Filed under C#
Have you ever seen the using statements at the top of your C# source files and wondered how exactly these work? I sometimes simply type them because I understand which classes I need, but if you look at the way a C# class source code is structured it is fairly easy to understand. So lets say I have a random/thought-up class called car and within that vehicle class I have a name space called car, boat, aeroplane. Now imagine that each one of the classes has a class called engine (because the properties and characteristics of engines in all three could be very different), then you would create three namespaces and within each namespace and create a class called engine, and remember all three these namespaces are part of a namespace called Vehicle. So the basic code would look like this:
namespace Vehicle
{
class Vehicle
{
}
namespace Car
{
class Engine
{
}
}
namespace Boat
{
class Engine
{
}
}
namespace Aeroplane
{
class Engine
{
}
}
}
And when you want to re-use those classes in other parts of your program, then you can add:
using Vehicle;
And to instantiate one of the Engine classes you would say:
Aeroplane.Engine aeroplaneEngine = new Aeroplane.Engine();
Thoughts on PHP
Posted by fr3dr1k | Filed under Web Development, Web Technologies
Wordpress runs on PHP, and PHP runs on Apache, this blog uses PHP and Apache to serve up content, and .NET doesn’t. So whats the point then? Well, for all intents and purposes I have a technology that can be used to develop and maintain large commercial websites without having to change to a .NET hosting provider. The point being that while I love .NET I cannot really develop commercially websites with it unless I pay for extra hosting and in these lean economic times I cannot see myself paying more money for hosting. That means that I have to rely on technologies such as PHP.
I have been reluctant to use PHP simply because the software tools available cost money, such as Zend Studio, but I did find PHP Development Tools as part of Eclipse and today I started doing some basic PHP stuff, and its amazing to see how easy it is to adapt to PHP if you have used C#. The syntax is very similar. One of the biggest differences between PHP and .NET is the way pages are handled. .NET uses postbacks, and all the .NET code is compiled, not interpreted. PHP on the other hand interprets its code and the way it basically works is that Apache passes a request over to PHP if it detects any PHP. The PHP interpreter then executes the PHP. As far as syntax goes PHP is similar to most programming languages. Features such as assignment operators and conditional statements are similar.
Silverlight Content Test in Wordpress and on Apache
Posted by fr3dr1k | Filed under ASP.NET, C#, Silverlight
What does it take to host Silverlight content on a site? Why would I want to publish Silverlight content on my website?
Well, to host Silverlight content on a website that runs Apache is not the same as running .NET content on IIS. Its kinda obvious that .NET content cannot and will not run under Apache. Remember though that Silverlight is a plugin, the same as Flash, and you are simply pointing to a file (XAP) that executes on the client side. Silverlight is a client side technology if you really think about it. I have in the week for instance, experienced that content will not immediately update on the client side even if you updated it on the server side.
It is thus possible to run Silverlight content on Apache, as this simple HTML document shows. It however seems that running Silverlight in Wordpress requires an iframe:
Why would I want to run Silverlight on Apache? There are many reasons I can think of and the list may grow or shrink depending on what I think is relevant for me, but here are some reasons:
- I can keep my C# skills and keep using Visual Studio. Why would I want to give up using one of the best and most powerful IDE’s in the world.
- Silverlight is a genuine Flash alternative and because it integrates so beautifully with Visual Studio and C# I can truly start developing great rich internet applications
