In this paper, we are concerned with the stability analysis and the design of stabilising compensation-based control algorithms for networked control systems (NCSs) that exhibit packet dropouts. In order to increase the robustness against packet dropouts for such NCSs, we propose a new type of model-based dropout compensator, which depends on the local dropout history. Moreover, we provide linear matrix inequality based synthesis conditions for such compensators guaranteeing robust stability. The analysis and design framework includes both worst-case-bound and stochastic models to describe the packet-dropout behaviour in both the sensor-to-controller and the controller-to-actuator channels. Numerical examples demonstrate the significantly improved robustness with respect to packet dropouts using the proposed dropout compensator, compared to using the existing zero strategy and the hold strategy.