We regularly use the .NET framework and C# to produce eye-catching websites, but just what are they and how are they used to develop web applications? You just press a few buttons and a pretty site appears, right? Wrong! It’s about time more people understood the work that goes into web development.
In the first of our guides for the lost and confused, we’re tackling C#. By explaining its basic functions and the software that it is used in, we’ll hopefully clear up what it does on a basic level. Before long, we’ll have you explaining C# to anybody who will listen, but read carefully to make sure you hit the right note.
C# (pronounced ‘C Sharp’) is a hybrid language created in addition to the existing C and C++ programming languages. Together with .NET, a software framework developed by Microsoft, C# can be used to develop websites and other web applications. It is an object-oriented language and one of the components that allow us to programme websites effectively.
As with all codes, a good place to start is usually with software and for C# this is more often than not Visual Studio. Used to interact with and manipulate code, Visual Studio offers a wealth of features all with the sole intention of helping developers build websites quickly and simply. One aspect that Visual Studio brings is the addition of Active Server Pages or ASP tags, a server-side script for dynamic web content.
At this point, there are two schools of thought when developing for the web – traditional web forms or Model-View-Controller (MVC). MVC is another subject for another blog post, but traditional web forms can be considered as comprising of two layers:
1. The front end which your users see. This consists of your average HTML mark-up and ASP tags, which form the interactivity on the webpage with features like textboxes, buttons and dropdown lists.
2. Supporting event handlers. These are optional ‘listeners’ that execute in response to actions, such as onButtonClick to handle a button click or key press, are attached to these.
An example of this structure can be found in the image below.
Whether grabbing data or performing a different action, C# reacts when an event handler is executed. Of course, writing classes in C# to hold data is a far better alternative to pulling data on the fly. It’s comparable to maintaining an organised filing system, being prepared as opposed to routing through everything when a request comes in.
C# and ASP go hand in hand; web development in this form cannot really exist without them both. C# on its own is a multifunctional code, but lacks specific functions required for web development – this is where ASP comes in. Together they are the bread and butter of web development and without them your website would just be simple filling with no substance or functions.
In many ways, the C# language is comparable to a librarian. It handles queries, pulls information and groups its findings into an output that people can understand. .NET provides the foundations, but it is C# that finds the requested material and does all the legwork.