Shanghai weather is characterized by generally mild winters and hot, humid summers. The best time to go is late September to November timeframe, when days are generally quite pleasant. The winter months, December through February, are typically chilly but not snowy. Late spring is the rainy season, usually extending from mid-April through end of May. The rainy season can be 2-3 straight weeks of endless drizzle and gray, dreary skies. July and August are hot and humid, so be sure to stay well hydrated (bottled water is available everywhere and very cheap). In August, an occasional typhoon will make its way toward Shanghai, but they normally hit well south of the city so Shanghai only sees a heavy rainstorm from it.
Two weeks to avoid are the first week of May and first week of October. These are national holidays and all of China is on vacation during these weeks. So be prepared for huge crowds at the airport, tourist sites, shopping areas, restaurants, and hotels.