You can validate that in javascript. Use the following code.
function Validate() {
var txtValue = document.getElementById("MainContent_txtTestBox").value;
var checkFlag = isNaN(txtValue);
if (!checkFlag) {
return true;
}
else {
alert("Number entered is not an integer");
return false;
}
}
For the textbox, just put the onkeyup event and specify the above function as the handler as shown below.
<asp:textbox id="txtTestBox" runat="server" onkeyup="Validate()" xmlns:asp="#unknown" />
Using JavaScript instead of server code (code-behind) would reduce the load on the server and improve performance.