Showing posts with label conditional statement. Show all posts
Showing posts with label conditional statement. Show all posts

Tuesday, 19 March 2013

ASP: conditional statements with If...Then...Else...ElseIf

   


In ASP we can use conditional statements in different ways. The basic syntax we are used to, is If ... Then ... Else ... End, however we will see that there are some interesting things about it.

First of all let's consider a simple conditional statement in ASP. As you already know, we do not use any brackets or parenthesis. A basic example could be:
<%
Dim numVar
numVar = 5
If numVar = 5 then
  response.write("The variable numVar is 5")
End if
%>

Tuesday, 26 June 2012

CSS & ASP: let the user choose the style

   


When we create a web site, we usually decide the look of it and the way the visitor is actually experiencing it. Sometimes we might need to create different look for the same site, especially if we are dealing with specific groups of users. I'm going to explain in a simple way how to let the user choose the style of the web page according to its needs. To do so, we are going to use CSS and ASP.

Friday, 27 April 2012

CSS: IE hacks

   


In March last year, I've published a post about CSS conditional statements. The article explains how to create conditional statements and load specific stylesheets for specific Internet Explorer versions.
We all know that, in order to guarantee a cross-browser full compatibility of our web sites, the above solution gives us a possible clean way out of the problem.
With that in mind, there are situations when we don't really want to create different stylesheets for each version of IE, and a simpler solution would be preferable.
Those are the cases where we can use the famous IE CSS hacks.

Wednesday, 19 October 2011

ASP: conditional update or insert record

   


There are situations when we need to insert or update a record in a table according to its presence. The condition is: if the record is already in the table, then update it, otherwise insert it.

Here we will see how to do it.

Some assumptions
To achive our goal, the first task is to determine which is the condition upon which we decide to update or insert the record.
I will show you an example, that will apply to a specific situation, however, after understanding the logic, you can think of something related to your personal goal.
In the following example, we have a table (table1) with 3 columns: id, field1 and field2. We have a form submitting data. Then there's another table (table2), linked to the first table through the id field. The columns of this second table are: id and field3.
The first table (table1) might have records linked to the second table (table2), while table2 already contains records. That is a classic situation in relational databases. The point here is that we know that a unique record is present in table2, and we want to insert a new unique record in table1 if it's not already present, otherwise we need to update it.
I hope that the above explanation is clear enough.

Monday, 28 March 2011

CSS: conditional statement

   


I usually write my CSS style sheets and check them with Firefox. It is probably due to fact that I use the Web Developer toolbar to check the resulting effects. When everything is exactly the way I want it, I start checking the result with IE, Chrome and Safari. Normally, there is no problems, however some times I find glitches, especially with IE 7 or IE 6.

The golden rule
First of all, let me tell you a thing that developers think it is some sort of golden rule. Every web site must look the same with any browser. That is not true anymore. Or, let me put this way, that principle is not an absolute rule anymore. With the introduction of CSS3 and HTML 5, developers have concluded that it is not a sacrilege to have different looks with different browsers. Do not jump to strange conclusion: I am not saying that we will have completely different sites for different browsers. However, we might accept that some particular effects (generated by CSS styles) would be visible only to users with updated browsers. For example, you may already know that IE9 will be available only for Vista and Windows 7. Win XP users will stay with IE8. Those users will eventually upgrade to a newer operating system, but in the mean time, they might not enjoy CSS3 or HTML5 new features. We will have to cope with that, it is a fact.