This paper is concerned with the control issue for a class of networked control systems (NCSs) with packet dropouts and time-varying delays. Firstly, the addressed NCS is modeled as a Markovian discrete-time switched system with two subsystems; by using the average dwell time method, a sufficient condition is obtained for the mean square exponential stability of the closed-loop NCS with a desired disturbance attenuation level. Then, the desired controller is obtained by solving a set of linear matrix inequalities (LMIs). Finally, a numerical example is given to illustrate the effectiveness of the proposed method.