The code above has no problem at all if not using AJAX. With Ajax extension however, the button "btnSearch" will be placed inside an UpdatePanel control to avoid the page being post-back. The MessageBox will not work as normal any more afterward. In such case, you might need to do some extra work on the MessageBox method.