Man cannot control sneezing while performing the prescribed Prayers. Sneezing may be understood as a blessing from Allah; hence, one is recommended to praise Allah for it even while he is offering Prayer. He can whisper softly “al-hamdu lillah” as reported by Imam An-Nawawi in his book Al-Adhkar.
Therefore, praising Allah while performing the Prayer because of sneezing does not invalidate one’s Prayer. However, a praying person must not respond “yarhamuka Allah” (may Allah have mercy on you) to another person who sneezes, as this will invalidate the former’s Prayer according to the juristic opinion of the majority of Muslim scholars.

Sheikh M. S. Al-Munajjid, a prominent Saudi Muslim lecturer and author, states: With regard to sneezing, it is reported in the Sunnah that a worshiper should say “al-hamdu lillah” if he sneezes. With regard to seeking refuge with Allah from the accursed Satan when hearing a donkey braying (while one is praying), there is no report in the Sunnah to that effect.
Sheikh Ibn `Uthaymeen said: “If a person sneezes while praying, he should say “al-hamdu lillah,” as was narrated in the sahih (authentic) report of the story of Mu`awiyah ibn Al-Hakam (may Allah be pleased with him) when he started to pray with the Prophet (peace and blessings be upon him), then a man among the people sneezed and said, “Al-hamdu lillah.” Mu`awiyah said to him, “< i>Yarhamuk Allah.” The people glared at Mu`awiyah, denouncing him for speaking. He said, “May my mother be bereft of me!” then they started to beat their hands on their thighs, indicating to him to be quiet, so he was quiet. When the Prayer was over, the Prophet (peace and blessings of Allah be upon him) called him. Mu`awiyah said, “May my father and mother be sacrificed for him. By Allah, he did not scold me or beat me or rebuke me. He said, ‘This Prayer should not include anything of people’s talk; rather it is saying Subhan Allah [glory be to Allah] and Allahu Akbar [Allah is Most Great], and reciting Qur’an’” (Reported by Muslim and Abu Dawud).
“The Prophet (peace and blessings be upon him) did not tell off the one who sneezed and said “al-hamdu lillah” while praying, which indicates that if a person sneezes during the Prayer he should say “al-hamdu lillah” because there is a reason for doing so. But that does not apply to every dhikr for which the reason for saying it occurs while one is praying” (Fatawa Ibn `Uthaymeen, 13/342).
And Ibn `Uthmaymeen was asked, “Is it permissible for one who is praying to say “al-hamdu lillah” if he sneezes, and to seek refuge with Allah if he hears a donkey braying? Is there a difference between obligatory Prayers and supererogatory Prayers in that regard?
He replied:
“With regard to saying “al-hamdu lillah” if he sneezes and seeking refuge with Allah if he hears a donkey braying, that is permissible according to the view favored by Sheikh Al-Islam Ibn Taymiyah (may Allah have mercy on him), but it is makruh (reprehensible) according to the well-known view of the school of Imam Ahmad. The more correct view is that favored by Sheikh Al-Is
lam with regard to saying “al-hamdu lillah” if one sneezes. With regard to seeking refuge with Allah when hearing a donkey braying, it is better not to do that. The difference between them is that saying “al-hamdu lillah” when sneezing is mentioned in the Sunnah and because it is prescribed by a specific command, unlike when a donkey brays, which does not concern him and the worshiper should not let himself be distracted by sounds outside the Prayer. With regard to the above, it makes no difference whether the Prayer is a prescribed (obligatory) Prayer or supererogatory Prayer.”