Archive for the ‘Tips and Tricks’ Category

How to set two background images for an HTML page ?

The other day I was wondering how could I set two background images for an HTML page and I came with one solution.
I don’t know if it’s the best way to do that but it worked as I wanted.
To explain the solution, here is the complete steps I made
First I had an HTML page without [...]

More »

Change the Office 2010 product key

A few days ago I received Office 2010 from work.
I installed it with the provided product key, and tried to activate it:

Unfortunately, the product key has been already activated for the maximum number of times permitted.

So I asked for a new key, I received it and I tried to change the key

After several researches, I [...]

More »

How to change the style elements of a listview? (the simple way)

With the ast.net listview control, you can set an AlternatingItemTemplate in order to change the display or what you want.
If you just want to change the backcolor or things like that, you can spare some time by using only the ItemTemplate and applying a diffenrent style depending of the index (use of the Container.DataItemIndex property).
example [...]

More »

How to use a ValidationSummary to display server errors?

Imagine you want to use your ValidationSummary to display server errors as client error, there is a simple way to do that.
First, declare your ValidationSummary, and a CustomValidator with Display property set to “None”

<asp:CustomValidator ID="ServerErrorCustomValidator"
Display="None" runat="server" ValidationGroup="MyValidationGroup" />

<asp:ValidationSummary ID="AdministrationTaskValidationSummary" runat="server" ValidationGroup="MyValidationGroup"/>

Next, in your application code, when an error occurs : set the CustomValidator’s ErrorMessage and [...]

More »

C#, check if a string is null or empty

In C# you can check if a string is null or empty in many ways :

string String1 = "testString";
if (String1== null || String1 == "")
{
// …
}
else
{
// …
}

string String1 = "testString";
if (String1 == null || String1.Length==0)
{
// …
}
else
{
// …
}

string String1 = "testString";
if (string.IsNullOrEmpty(String1))
{
// …
}
[...]

More »