Biocompatible crosslinked polymers, and methods for their preparation and use, are disclosed in which the biocompatible crosslinked polymers are formed from water soluble precursors having electrophilic and nucleophilic functional groups capable of reacting and crosslinking in situ. Methods for making the resulting biocompatible crosslinked polymers biodegradable or not are provided, as are methods for controlling the rate of degradation. The crosslinking reactions may be carried out in situ on organs or tissues or outside the body. Applications for such biocompatible crosslinked polymers and their precursors include controlled delivery of drugs, prevention of post-operative adhesions, coating of medical devices such as vascular grafts, wound dressings and surgical sealants. Visualization agents may be included with the crosslinked polymers.