Very broad question, so the answer would be very broad.
Basically you'd be either using the Page_Load method (and checking IsPostBack) or calling your own on method, which gets run at "the end" of the life cycle (simplified).
But this is basic Asp.Net stuff and not really something that is Sitecore specific. The only thing to watch with Sitecore is if the layout/sublayout etc is cached, as this is output caching and a postback will just return the same html as before.
And if I was to do something like generate af pdf from the current page, I'd use a GET and just link to the same page, but with something in the query string that hits another Device, that does the PDF rendering. Eg. /news/2012/news1.aspx?pdf=1
Browsers handle GETs better with regards to the Back button and using a POST for something that changes data (see http://www.w3.org/2001/tag/doc/whenToUseGet-20040321#checklist )
But as I said I sound to me more like what you need to look into is standard Asp.Net
I hope this helps.