"MessageBox" and "alert" are incompatible: they are used in different environments.
MessageBox is only applicable to Windows applications - if you try to use them in web projects, they will not work.
Alert is only applicable to web projects - they can't be used in Windows projects.
And probably, your problem is that Convert.ToInt32 is a bad idea. If the value you try to convert is not a valid integer, it throws an exception - and your Windows application (or thread) will crash unless you catch it, or your web application will fail and probably show no response.
Trying to use them both is a recipe for disaster, as MessageBox is modal and will do nothing until the user - who can't see it - clicks a button.
Instead of Convert, always use TryParse, and report problems properly:
int first;
if (!int.TryParse(txtfrst.Text, out first))
{
... report problem to user ...
return;
}
You can then use converted values in your validity tests without risk of your app crashing.
And work out what system you are working on, and look for the appropriate communication method!