Author Archive

C# ASP.NET – GridView : How to Use Checkbox in Gridview to Select Multiple Rows

2009-01-06

I wanted to select multiple rows of the grid view using check boxes to select each row.

In this post I will discus how and what I did to achieve this goal…

I used a template column which holds a check box to select or de-select a row in the grid view.

Adding a Template Column:

There are several simple ways to add a template column/field to your grid view:

  1. Select your grid view and then click on the small task button (the small square button located to the top right corner of the grid view control) and select “Add New Column…” from the “GridView Tasks” box.
    1. Use “TemplateField” as the field type
    2. Provide a header text
    3. click ok
  2. Or… Select “Edit Columns…” from the “GridView Tasks” box and
    1. Select “TemplateField” from the “Available fields: ” section
    2. Click “Add” button
    3. Provide a header text in the “TemplateField properties: ” section
    4. click ok
  3. Or… Select “Columns” from the grid view properties and follow the steps described in the earlier method (2nd one)

Adding a Checkbox to the Template Column:

  1. Select “Edit Templates” from the “GridView Tasks” box. Then it will show you the inside of the template.
  2. Select “Item Template” from the “Display: ” drop down list.
  3. Drag and drop a check box in the item template area.
  4. Give an id as “chkid” for the check box – You can use a different name if you want but make sure you don’t confuse when I use this name in later parts of this article.
  5. Click “End Template Editing” from the “GridView Tasks” box.

If you have completed the above steps correctly, you should see the expected checkbox column added in to the grid view.

Design View
As you can see in the image above, in my example I use a Name column along with the check box column to make this clearer.

How to Databind the Template Field:

I use a datatable to populate the gridview so we have to databind our two columns.

The second column name is a “BoundField” so to databind it simply specify the name of the data table column you want to bind to this column in “DataField” property under “Data” property set in the fields dialog box you get when adding the second column (use one of the ways I described above to add a column).

Databinding the template field is a bit tricky, but not hard.

  1. Click “Edit Templates” from the “GridView Tasks” box so that you will see the check box.
  2. Click on the small button with a triangle in the upper right corner of the check box which is similar to the one we clicked on the grid view to get the “Checkbox Tasks” box and then click on the “Edit Databindings…” link inside that box.

You can use this dialog box to bind any property of the control to a data source column

In this example we will bind the “Checked” property of our check box to a Boolean column called “Selected” of the data source.

For that:

  • Select “Checked” from the Bindable Properties section and enter following in the Custom Binding section:
    • DataBinder.Eval(Container, “DataItem.Selected“)
  • Note: the word “Selected” (in red color) refers to the “Selected” field of the data source.

Populating the GridView:

As I described earlier I create a simple data table in the page load, populate it with some dummy data and then bind the grid view with it.

Note: I have used several methods to add data to a table to illustrate those to you.

The Code:

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("Selected", System.Type.GetType("System.Boolean")));
dt.Columns.Add(new DataColumn("Name", System.Type.GetType("System.String")));

DataRow dr = dt.NewRow();
dr.ItemArray = new object[] { false, "Cassian" };
dt.Rows.Add(dr);
dt.Rows.Add(new object[] { false, "Menol" });
dt.Rows.Add(new object[] { false, "Razeek" });

this.GridView1.DataSource = dt;
this.GridView1.DataBind();
}
}

There are several things that I’d like to bring to your notice:

  • I have checked for postback to make sure this data population is not occurred in general post backs. The reason is the framework refreshes when the grid view is re-bound.
  • So if we don’t do this check, whenever we click on a check box, a postback occurs, the grid gets refreshed, the check boxes get cleared, we cannot keep track of what check boxes are selected…!
  • As illustrate in my code, you can either first populate a datarow and then add it to the datatable
  • Or you can directly add the items using only one line of code.

Retrieving the Status of Checkboxes:

Now we have completed the interface and the user now can select several rows of the grid view using the appropriate check box.

The next step is to capture the rows that the user has selected.

In my example, I have used a button, once clicked; it will display the list of names of the selected people.

I will introduce the code first and then explain it to you.

protected void Button1_Click(object sender, EventArgs e)
{
ArrayList names = new ArrayList();
foreach (GridViewRow gvr in this.GridView1.Rows)
{
if (((CheckBox)gvr.FindControl("chkid")).Checked == true)
{
names.Add(gvr.Cells[1].Text);
}
}

this.Label1.Text = string.Empty;
foreach (object itm in names)
{
this.Label1.Text += " " + itm.ToString();
}
}

Note following:

  • The code iterates through each row of the grid view using a for each loop, takes the Name field from the selected rows and then adds those names into a arraylist
  • The GridViewRow refers to a single row in a grid view
  • Control Control.FindControl(string controlID) – GridViewRow class provides this method to find a specific control within a grid view row. This method becomes very handy in situations like this where we cannot directly access the control from the code because those are generated at run time
  • FindControl returns a control so you have to explicitly cast the returned control to the type of it

Screen Shot:

21

Conclusion:

We can use a template field with a checkbox to allow user to select multiple rows using checkboxes associated to each row. When the button is clicked, checkbox of each row is checked for its status and the row is selected if the user has chosen it.


Was this post helpful to you? How can I improve? – Your comment is highly appreciated!

Cassian Menol Razeek


How Fibonacci Sequence Relates to Nature

2009-01-05

Italian mathematician Leonardo Pisano had a problem worked on to find a mathematical pattern to answer the question: how many pairs of rabbits can be produced from a single pair of rabbits in one year?

He carried out his work on following assumptions:

  1. Rabbits are kept under optimal conditions
  2. Female rabbits always give birth to pairs
  3. Each pair consists of one male and one female

If we start with a pair of new born rabbits and monitor the population monthly…

Rabbits cannot reproduce until they are at least one month old. So in the first month there will only be one pair and at the end of the second month the pair is able to reproduce so the female rabbit will give birth to a new pair.

In month three the original pair gives birth to yet another pair while their first pair of baby rabbits grows to the adulthood.

In the beginning of month four there are two pairs of adult rabbits and one pair growing so both of these adult pairs give birth to two new pairs. So the total number of pairs in the end of the fourth month:

Adult pairs : 2
Growing pairs : 3
Total : 5

Like wise the pattern goes on as follows:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, … on to the infinity. Each number is the sum of the previous two.

Leonardo Pisano found this interesting pattern on 1202. How come the pattern is named Fibonacci Sequence?

Leonardo Pisano was also knows as Fibonacci, meaning “son of Bonacci” giving this name to his finding.

Are rabbits the only species having relevance to Fibonacci Sequence?

Many natural entities such as Fruits, Vegetables and Seed Heads show spiral patterns which follows Fibonacci Sequence.

Some examples:

If you look at the array of seeds in a center of a sunflower you should notice that those seeds are arranged in spiral patterns curving left and right. And the amazing thing is if you count the number of these spirals you will get a Fibonacci number. The most amazing thing is if you divide the spirals pointed to left and right and count those separately you will get two consecutive Fibonacci numbers!

If you look at a pineapple you can notice that its scales make a spiral pattern and if you look closer and count those scales in each spiral you will notice that those numbers reflect Fibonacci Sequence.

Same thing can be noticed in pinecones, cauliflower and many more natural things we live with.

This sequence has an amazing link with the nature and that’s may be why the ratio between two of these numbers is called The Golden Ratio.

The Golden Ratio:

Two numbers are considered as in The Golden Ratio if the ratio between the sum of two numbers and the larger one is equal to the ratio between the larger one and the smaller.

In mathematics the golden ratio is often denoted by the Greek letter ϕ (phi).

The value of the golden ratio: ϕ = 1.6180339887…

Was this post helpful to you? How can I improve? – Your comment is highly appreciated!

Cassian Menol Razeek


My Goals for the New Year 2009!

2009-01-01

It’s a New Year…!

I want to be much more improved in both my personal and professional lives when I look back at the end of this New Year!

So I decided to make a list of goals I want to achieve in this year. And I will make sure that I achieve my goals as I go on living this New Year.

Goals for My Professional Life:

I have a set of goals which will improve the quality of my professional life and will increase the value of me in the profession. If I directly go to the list…

  1. Obtain MCTS Certification
  2. Obtain SCJP Certification
  3. Be More Competent on My Work at My Office
  4. Make My Clients Happy
  5. Find More Freelance Work
  6. Create Several Methods to Earn Some Money Online

Goals for My Personal Life:

  1. Keep My Family Happy
  2. Focus More on Health of My and My Girl Friend’s Parents
  3. Cut Extra Fat I Have Gained and Get the Body I Used to Have
  4. Learn to Play Guitar – ANYHOW!!!
  5. Go to Swim

My Financial Goals:

  1. Open a Fixed Deposit Before the End of June

Other Goals:

  1. Obtain Work Permit
  2. Give Clothes Regularly to Children of a Poor Family

These are the Goals I have in my mind at the moment and I will update the list as I go on…!

Yes, I know, I will have to work so hard if I want to have all of these achieved at the end of this year. I will definitely make this dream come true with the great help from my parents, my girl friend and all my friends around me and always the best helper, The God!

I wish the whole world, a Happy and Successful New Year!

Cassian Menol Razeek


Looking Back at 2008!

2008-12-31

I am not happy about my last year because I did not make much significant achievements on my carrier in the year! At the beginning of the year I had a goal to obtain MCTS certification but I could not achieve that.

However there were some small achievements as well:

What I feel as the best achievement of the last year is this blog itself. I made this on November and I am very happy about this because it feels so great to see someone out there is reading my posts.

A software solution provider company chose me as a technical consultant to solve their problems and I am so happy that I could solve many problems that many of their staff could not solve. I consider this as one of my major achievements of the last year.

I have survived in my work place and after taking the recent lay-offs into my consideration, I would take this as an achievement!

I could take my family on a trip and they were so happy about it and we all enjoyed it. It was the best personal achievement for me!

Also me and my girl friend could go several short picnics to beautiful places like beaches. Those were romantic achievements to me because those moments brought us even closer to each other!

I don’t remember everything I achieved or missed through out the last year at this moment so I will publish this post at this point and will update as I remember…!

Cassian Menol Razeek


ASP.NET – AutoPostBack : What is AutoPostBack and How AutoPostBack Works

2008-12-26

Today I was experimenting on a grid view where I was trying to select multiple rows of the grid view using a check box column.

I wrote some code in the CheckedChanged of checkbox but then I found that the code was not executed when the state of the checkbox is changed.

So I did a little googling and found out about this AutoPostBack property. This property defines whether the control should post back to the server each time when the user interacts with the control. Or, according to this scenario, a post back will fire when the user clicks on the check box or when the Checked property is changed.

AutoPostBack :

This value holds a boolean value (true/false)

If the property is set to true, a post back is sent immediately to the server and no post back is occurred when set to false.

The Use of AutoPostBack:

According to MSDN, for most WebControls, when AutoPostBack is false, only the events from actions that cause a net change in the state of the control are submitted to the server.

In other words some events are not queued to the server. For example no event is fired when a user selects a value from a drop down list or when user presses Enter or Tab key after entering a value to a textbox.

If you want such events to be fired then you have to enable autopostback by setting autopostback property to true.

How AutoPostBack Works :

When AutoPostBack is enabled, the .Net framework automatically injects following additional items into the generated HTML code.

  1. Two Hidden variables with name __EVENTTARGET and __EVENTARGUMENT
  2. A Java script method with name __doPostBack (eventtarget, eventargument)
  3. OnChange JavaScript event to the control

What is __EVENTTARGET :

__EVENTTARGET tells the server which control wants to fire the event so that the framework can fire the event on that control.

What is __EVENTARGUMENT :

__EVENTARGUMENT can be used to provide additional information to the server about the event.

What is __doPostBack (eventtarget, eventargument) :

Parameters sent to this method holds relevant target and event argument values and this method sets those values into __EVENTTARGET and __EVENTARGUMENT hidden variables so that the server can read those.

Then this method submits the form to the server where the appropriate event will be fired.

What is OnChange JavaScript event to the control :

Every control has a client side event called OnChange. When AutoPostBack is enabled for a control the framework sets the handler for this client side event as the __doPostBack method and will pass the name of the control as the first parameter, eventtarget.

Ex/

Following shows how the framework binds the __doPostBack method to the OnChange event.

<input type=”checkbox” onclick=“javascript:setTimeout(‘__doPostBack(‘CheckBox1′,”)‘, 0)” />

Was this post helpful to you? How can I improve? – Your comment is highly appreciated!

Cassian Menol Razeek

Recommended Books:


How to Save a Copy of a Visual Studio 2005 Solution

2008-12-22

Sometimes things we consider as simple take much time to be accomplished than we expect just because we forget!

Today I wanted to save a copy of a web based visual studio 2005 solution but it took life 10 minutes for me to accomplish that because I had completely forgotten the method to do it. Since keeping track of what I learn is one objective of this blog I decided to include this small detail today.

How to save a copy a solution in visual studio 2005 (Save As)

Select the solution (click on it) in the solution explorer

Now go to File menu and there will be a command to Save the solution to any place you want.

Ex/

If your solution name is “My Solution.sln”

When you select your solution in the solution explorer and go to the file menu, you will see command like:

Save My Solution.sln As

Simply click on that and you will get the usual Save As dialog box.

Some Details

Even though you can select the place to save project files in web based solutions such as web sites, the solution is saved in a different location which is located in your My Documents folder.

The solution file contains information about your projects and files including paths so if you want to move the entire solution to a different computer to continue work on a different workstation then this tip will become handy unless you don’t forget things as I do :-D

Was this post helpful to you? How can I improve? – Your comment is highly appreciated!

Cassian Menol Razeek

Recommended Books:


Internet Explorer Major Security Flaw!

2008-12-16

Internet Explorer, one of the most widely used Microsoft products, Considered as the world’s most popular web browser has received a Red Alert!

The situation was raised when Andreas Sandblad from Sweden reported a vulnerability to Microsoft.

The vulnerability:

Point of Origin: The Cross-Domain Security Model

Fix: Not Available Yet, Microsoft is still investigating on this

Description:

This Cross-Domain Security model is supposed to keep windows of different domains from sharing information.

An Incomplete Security Checking has caused Internet explorer to allow one web site to potentially access information from another domain loaded into a different Internet Explorer window when using certain dialog boxes.

The vulnerability would allow a malicious web site to load malicious code into the client’s system. Not only that, through this security hole, an attacker can either execute any executable available in the victim’s system or perform any action that is entitled or available for the privileges of the victim.

For an example, if the victim is an administrator on the system the attacker can perform critical actions as the attacker now has administrator privileges on the system.

The Spread:

According to Trend Micro, due to this vulnerability, more than 10,000 web sites have already been compromised to take advantage of the flaw!

Many web sites which are mostly Chinese have been used to steel computer games passwords which have good prices in black market.

Affected Version(s) of IE:

According to Microsoft, so far attacks have been found only for version 7 but they warned that other versions were “Potentially Unsafe”

How to Protect Yourself:

The advice given by computer security experts at the moment is to switch to a different web browser till this major security flaw is fixed.

Was this post helpful to you? How can I improve? – Your comment is highly appreciated!

Cassian Menol Razeek


5 Ways to Get Rid of Financial Stress and Optimal Utilization of Money

2008-12-14


With the rise of Global Financial Crisis, Financial stress has become a hot topic in the Internet. Since I am also a victim, I thought to make a small research on this. In this post I am trying my best to explain what I gained during my research. I hope you would find this interesting!

We go to school, high school, university, technical colleges, … etc. then we find a job, then focus on collecting additional qualifications to climb the ladder… etc.

Why do we do these things? Yes to have a happy life, to make the life better.

If we keep the other factors like qualifications apart for a while, we earn money to make sure we have a happy life but in the middle of the way we become exhausted and stressed out just because of money which is meant to make our life better.

100 people would give 100 explanations for this as different people could see this from different angles. Some may say it’s a foolishness to make the life stressed out for money while some other would say that it is worth taking that stress because there’s almost nothing that can achieved without a sound financial standing.

In this article, I am not trying to elaborate on these complicated and human dependent explanations but rather I would introduce the five ways that I found as helpful to reduce financial stress and I will try to inject my experience into each method when ever I feel applicable.

1 Separate Needs from Wants

It would be safe if I say that we are living in a world where marketing plays a major role. For any industry, marketing has become a crucial factor.

Today’s marketing professionals are very tricky and would sell a ‘trip around the world’ ticket at a gas station for a guy who simply stops for a quick refill.

As a result of this tricky marketing environment most of us have become unable to separate our needs from our wants. For an instance someday in last month I went to a super market to buy cartridges for my Gillette 7 ‘O clock razor which I have been using for more than a year but I came out with a Gillette Mach3 razor because there was a perfectly organized marketing campaign inside the supermarket which could make me literally forget what I had planned to buy. I knew I was going for something which was not crucial for me or something I want, in other words but I could not help myself out of the situation.

So how could we overcome such situations without doing exactly what marketing guys expect from us? Well, different people use different strategies. Some people don’t keep credit cards, some people don’t keep extra money, etc. Even though these methods look very effective (and may be they are effective) these methods have their cons as well. Like we can never replace the benefits we get from credit or debit cards from money.

Well, I know this sounds like impractical but I still believe in controlling the thought itself. Even though I have not met perfection, I have practiced this for some time and it works to some extent. What I do when I meet something that I want is make a small argument in my heart where I think what would I lose if I spend for this at this moment. So, most of the time, I have seen that my short term financial goals get affected by purchasing such things. At that time it becomes much more comfortable to leave the place without buying it.

As I leave the place without buying…, I think like, “What’s the big rush, I can allocate some money for this in next month’s budget and buy this…” so I don’t become disappointed at that moment.

2 Change the Attitude Towards Money

This is something I newly learned from my research. I was used to be very upset when I don’t have as much as money I thought that suit my qualification and experience levels. This truly leads us to a huge stress because we always feel disappointed and spend most of the time thinking what we cannot achieve with current financial standing. So how can we possibly get rid of these feelings? Well, I could find many suggestions such as meditating and yoga I am not against these methods buy I believe more on the other thing I learned which is positive thinking. We usually think about what we cannot do but we rarely think about what we cannot do.

I was used to be sad when I see when other people are traveling by their cars while I ride my bike. But I never noticed the significantly larger number of people who walk while I ride…!

3 Ask for Help

This is something most of us don’t like to do! In many societies asking for financial help is considered as an act of weakness but we can always ask for help or instructions to improve our financial management skills. If we get the right help at the right time to improve this skill, we will be able to survive in many financial problems without asking for direct financial help.

4 Don’t Keep Debt

What am I talking? Nobody likes to keep debt….!

Yes, it’s true, but the reality is we do keep debt around us. The most common trap for most of us is credit cards. Most of us think these paper-like pieces of plastic have amazing powers to bring things that are impossible to achieve with the power of our monthly wages.

The very simple yet strong truth is “Nothing Is Free”. Credit cards only bring the good to our hands and put the payment to the future. Of course this becomes a great help in certain situations.

I do not blame credit cards or credit card owners. A credit card is a powerful tool like fire, if we use it wisely we can make our day to day life much better and of course if we lose the grip we are doomed!

The most common mistake people do with credit cards is paying the minimum due payment and let the interest add up. I have this great lesson learned from my first credit card. I used that credit card so freely and paid the whole amount regularly in the beginning but eventually I started to pay only the minimum payment due. The interest kept growing and I did not care for about a year and I only realize how much I have paid when I made the sum after my father instructed me. I had paid several times of my initial amount of debt as interest.

After that incident my father gave me a nice advice. He said:

“Id doesn’t matter how you pay or when you pay, you do have to pay your debts someday. The only difference is you have to pay with an extra interest if you pay late, so why not pay it at the first possible time and save the interest?”

5 Make a Budget and Stick to It

Most of us already are good in making a budget. It’s the later part that makes us sweat! How to stick to the budget?

Well, in this case we have no excuses against paper work! We have to have a clear idea on our fixed expenditures such as phone bills, water bills, etc. We cannot skip paying these bills so we must allocate funds to these expenditures as the very first step.

Then make the list of other expenditures you wish to make in this month such as that handy new razor, expensive perfume, New Five star dines, Oh what am I doing? You don’t need examples on this. Do you?

The listing is always fun but then comes the worst part; you have to prioritize these expenditures and cut the less important ones. I know it’s hard! Keep in mind that this is your own good when allocating money…!

Wait…! Before you allocate money for the second type of expenditure we just discussed, allocate a certain amount of money as the saving for the period and consider it as an important expenditure you cannot cut so that you will not consider your saving as an option in the middle when executing your planned budget.

Basically, this is the whole idea behind a happy life with a less (I wouldn’t say “no”) financial stress.

Before we end this discussion, I’d like to remind you that we do need money to live this life and we do have to earn it! The most important thing is we have to make sure that in the middle of the way while trying to make money, we should not forget the fact that we have to use money to bring HAPPINESS into our life.

Money alone can do nothing but money and a wise mind can do anything!

Was this post helpful to you? How can I improve? – Your comment is highly appreciated!

Cassian Menol Razeek


Computer Hardware – Memory : Static RAM Vs Dynamic RAM

2008-12-10

Random Access Memory plays a crucial role inside a computer. RAM is where the processor keeps the data it needs to work. The computer always has to load necessary data into the RAM because the speed of hard disks is very low for processor to work with.

Actually even the RAM is not fast enough for the processor so computers use many types of memories in different places such as cache or registers for different purposes. The purpose of this article is not to elaborate on how RAM works so without wasting time I will go into our topic.

Basically, there are two types of RAM which are Static RAM and Dynamic RAM. In this article we will compare these two types of RAM focusing on following aspects:

  • How these two types are designed
  • How these operate
  • Issues with each type
  • What is the most fast and what is most cost effective
  • Where these memories are used in our computers

Dynamic RAM

This is the most common type of RAM in use today. In a dynamic RAM chip, a bit is stored in a single memory cell. Each memory cell includes a transistor and a capacitor. Thanks to the revolution of technology these transistors and capacitors have become extremely small so that a single chip can hold millions of memory cells.

How these cells operate

In a memory cell, the capacitor holds electrons to store a binary 1. To store a binary 0, the capacitor is emptied. The transistor serves as a switch to allow the memory controller of the chip to read or change the state of a capacitor. In other words, the memory controller which is a circuit operates through the transistor to either empty the capacitor to store a binary 0 or to fill the capacitor with electrons to store a binary 1.

Problem with dynamic RAM

The problem with capacitors is capacitors have leakages so those can’t keep electrons for a long time without getting discharged. So in a dynamic RAM either the CPU or the memory controller has to recharge all capacitors which stores binary 1 before those get discharged (it’s not necessary to recharge capacitors which represents binary 0 because those capacitors are needed to be empty). This automatic refresh has to take place thousands of times per second. This refresh process takes time and therefore slows down all memory operations carried out on dynamic RAMs.

Static RAM

Static RAM stores a bit in a completely different mechanism called flip-flop which does not need a recharge. A flip-flop is an advanced yet interesting topic so keeping that for a future discussion I will publish only the definition of what is a flip-flop which I believe is enough to understand the scope of this article. A flip-flop is an electronic circuit that has two stable states and thereby is capable of serving as one-bit memory. Static RAM is made of an array or a collection of flip-flops.

Since flip-flops do not use capacitors, static RAM does not need to be recharged. So this property makes static RAM faster than dynamic RAM.

Ok now what’s wrong with Static RAM?

To implement a flip-flop it takes 4 or 6 transistors so Static RAM takes more space compared to dynamic RAM leading to a less memory per chip ratio and static RAM takes more electronic components than dynamic RAM to store a bit which then makes static RAM much more expensive than dynamic RAM.

Finally, where in my computer can I find these memories?

Since Static RAM is fast and expensive whereas Dynamic RAM is cheaper and slower, the speed sensitive cache area in the CPU is made of Static RAM while the large RAM area is made of comparatively cheaper Dynamic RAM.

Was this post helpful to you? How can I improve? – Your comment is highly appreciated!

Cassian Menol Razeek


What is a Trojan Horse and How does it Attack Computers?

2008-12-08

A Little History

Trojan War is considered as the most significant conflicts in Greek mythology.

This is where Trojan horse comes into play for the first time. The great warrior Odysseus brought this strategy to find a way into the city of Troy. He commanded his army to make a massive wooden horse large enough to host several Greek soldiers in it.

Then all Greek soldiers fled from Troy except for great warrior Odysseus and several other warriors who hid inside the wooden structure.

There was another man called Sinon was sitting duck to the enemy. His duty was to make sure that the Trojans take the bate by convincing them that his fellow Greeks had betrayed him and fled from the city. He convinced the Trojans that the wooden horse left by Greeks is safe and would bring them luck.

Even though Trojans had already defeated the Greeks they still wanted more luck and decided to wheel the horse through their gates unknowingly granting the Greek enemy access to the city of Troy where all of Trojans were partying after proclaiming victory.

Without noticing the handful of great enemy hiding inside the giant horse standing in the middle of them, the citizens of Troy went to sleep after the huge parties took all over the city.

It was the hour of Odysseus and his men who were patiently waiting for the moment. They sneaked out of the horse, to which the Trojans were praying a while ago, and wreaked havoc on the city.

Back To Computer

I gave that brief idea about the history of the Trojan Horse to give you the impression of the computer Trojan Horses.

Computer Trojans are exactly as same as the first Trojan Horse. A Trojan is a small program embedded into a harmless program such as a game, animation, etc.

Trojans do not spread themselves as computer viruses. It needs the computer user to initiate it. In other words, when you try that new game you got free from a web site, the Trojan inside that gets installed into your computer without your understanding.

The worst thing is since the Trojan is executed by the computer user, Trojan gets the same set of privileges as the user does. So if you are an Administrator and you play a game with a Trojan, you grant all rights that you have to the Trojan, Just like what happened in Troy!

Most Trojans connects to its creator from the infected computer. These computer geniuses who use their skills to cause damages to the public are called Crackers. If anyone carelessly opens an untrusted program and launches a Trojan, His or her computer can be controlled by the cracker for his malicious work. These computers are called Zombie Computers because the real owner of the computer doesn’t even know that his computer is been controlled by a different party.

Crackers use networks of zombie computers to send more viruses or to get anything done. These networks are called Botnets.

How to protect yourself form Trojans?

There are very basic and simple precautions to follow:

  • Never open any attachment/file sent by unknown senders
  • Never open any file you receive without scanning for threats (even if it’s from a very close friend. Because he may already be a victim and can be sending Trojans with his mails without knowing)

You must have seen and heard these precautions more than you have heard or seen about threats but we never tend to follow these and that’s what crackers always want.

An Example; Trojan Horse I Made Some Time Ago…

Well, don’t take me wrong, I also have made a Trojan once but it was not to damage anyone…

When I was in my first job where I met my girl friend, before going and ask her, I wanted to run a check on her computer to see if I could find any evidence of a boy friend :-)

At that time I already had made a TCP/IP chat software. So what I did was I made a nice animation of Winnie the Pooh and embedded a Trojan which could read the password file in her computer it was easy because she launched my Trojan with her admin rights. So while she was enjoying the Winnie the Pooh animation which I downloaded from the Internet to decoy her, my Trojan read her password file and sent all entries to my computer through TCP/IP which I could capture using my Chat Server.

Then it was only a matter of a brute force attack to get her password. I still remember her password :-D

I told her about it very soon and she was amazed to hear her password from my voice! And of course it was a plus point for me too :-D

So the conclusion I want to make here is that a Trojan is a very powerful concept which can be used by your enemies to use your own powers and privileges to take control and harm your computer and many others. So always be careful when dealing with email attachments and executable files.

Being extra cautious is always good and can protect you from many threats…!

Was this post helpful to you? How can I improve? – Your comment is highly appreciated!

Cassian Menol Razeek


  • Visitors Since Oct, 2008
  • Copyright © 1996-2010 I Learnt Today.... All rights reserved.
    iDream theme by Templates Next | Powered by WordPress