It is simple. You can use it as you use normal controls at runtime.
It will be something like below:
AjaxControlToolkit.ModalPopupExtender mpop = new AjaxControlToolkit.ModalPopupExtender();
mpop.TargetControlID = "";
mpop.PopupControlID = "";
mpop.CancelControlID = "";
this.Controls.Add(mpop);
Hope that helps.