Though riding on the sidewalk is generally a bad idea, I believe the legality of it is up to local governance. Here in El Cajon, I think it's illegal for an adult only in business districts. Violating this can get you shot in the face:
http://www.utsandiego.com/news/2013/...-cajon-police/
I do climb Fletcher Parkway's sidewalk out of El Cajon for a mile on the way home, but it's in a park, uphill at 6-7% the whole way, with no cross traffic. So far, haven't been shot in the face.