Going into the red (anaerobic) at any point on a climb is a recipe for disaster. To keep a steady pace, break your climb into thirds and it should go like this:
First 1/3: Pedal easier than you have to. Even if you think you're going slow enough to make it to the top, chances are your fresh legs want to pedal slightly faster than they should be. Slow your pace and make this section easy.
Second 1/3: Steady. No need to go overboard. Conserve energy in this section and get into a rhythm. Be careful not let your heart rate climb to anaerobic levels at any point. Slow and steady wins the race.
Third 1/3: This is when things get difficult. Try to maintain your pace from the second phase, and as you near the top give it everything you have left.
The best time to get into the right gear is before the climb begins. If you wait until the ascent starts to shift, the sudden decrease in speed will kill any momentum that you may have.
It's also harder to shift when your chain is under load. Prevent dropping your chain or having your gears stick by shifting before pedaling becomes difficult.