What you are trying to do requires a seperate class library. Please see this article:

http://www.codeproject.com/cs/files/ads.asp