When we cough, we can initiate what is called the vagal reflex. That can make you feel faint. The vagal nerve controls the pulse and things like coughing, straining on the toilet, cold water, vomiting or holding your breath can all stimulate the vagal reflex, resulting in a temporary slowing of your pulse/heart beat, with lightheadedness the result.
Of course, the best way to avoid that feeling is to prevent coughing with effective asthma treatment. But if that doesn't always work, then at least be prepared. If you start to feel faint, sit down and put your head between your knees or lie with your feet higher than your heart. That should help relieve it.
To your health,