Probably the single most important thing is a single warp, about 1.5 times the length of the boat, attached to both the bows and the stern. You can step ashore with this from any point along the length of the boat while retaining control of both bow and stern.
The precise technique depends almost entirely on what sort of boat, what sort of locks and how strong/agile you are.
All depends on the depth of lock and whether you are going up - or down.
Main thing is to give yourself plenty of time.
1st thing when entering a lock to go up is that you may not be able to attach your stern rope - or if the canal is full of water and there is an outpouring from the higher reach - your bow rope. You may have to climb a ladder and search for a cleat/hook/ring to attach to - there fore you have to judge the height of the lock and allow enough warp which should be tied off on a cleat on the boat.
You may have to act quick quickly. Beware if there is a wind blowing in or out of the lock and also a cross wind as you may end up with the boat in the middle of the lock.
I would strongly recommend two lines - or one line connected to bow and stern. With a single line to a centre cleat, should you loose control you don't stand a chance of recovering the situation.