Im trying to install a replacement light and the box has 2 black, 2 white and 2 ground wires, but my fixture only has one of each. I didn't really pay attention when i was pulling everything apart... Anyway, the light is now on and won't turn off so I'm guessing just wiring all black to black, all white to white and all ground to ground was a bad idea.
How should this be done?
EDIT: We used a voltage sensor and discovered that one line is always hot. Wired it to one of the white lines and hooked up the others to the light. We now see intermittent flickers, but it won't light up. Wondering now if I did caused damage to the dimmer switch earlier. Will put a regular switch in and see in the AM.
EDIT 2: Dimmer switch was bad. Janessa's answer explained what was going on, and the two comments below are correct in saying I shouldn't be working on it.