How can I change the action of a form through code?

You can't change it. The action attribute is owned by ASP.NET. Handle Events and Transfer.