write this code on the click of your button
if(!string.IsNullOrEmpty(txtName.text))
this.modalpopup.show();
dont set the target controlid of your button same as this button as it will not allow to post back and fire the click event.
Feel free to ask any another doubt regarding the same.