Is it permissible to sell things inside the mosque for charitable purposes, where the profits will be used to help a charitable organization, i.e., helping Muslim orphans and poor people – for example, selling books and tapes, and donating all the proceeds to the charity work?

Praise be to Allaah. 

It
is not permissible to buy or sell in the mosque, whether that involves
books or anything else, even if the proceeds are to benefit orphans
etc. But there is nothing wrong with putting them in a special box and
writing the prices on them, and putting a money-box with it so that
whoever wants a copy can put the money in the money-box and take a copy,
without any bargaining, haggling, offering or acceptance. And Allaah
knows best.