I am using ASP.NET 2.0.
I have various ASP.NET Server Controls like TextBoxes on my Entry Form. I want to pass TextBox value on onBlur event. A sample TextBox code is as below:
<asp:TextBox ID="txtTotalTw" Width="80px" runat="server" MaxLength="10" onBlur="isNumber(this.Value);"></asp:TextBox>
In the code-behind I added below line:
txtTotalTw.Attributes.Add("onBlur", "javascript:isNumber(this.Value)");
The JavaScript is below:
<script type="text/javascript" language="javascript">
function isNumber(n) {
alert(n);
return !isNaN(parseFloat(n)) && isFinite(n);
}
</script>
I added alert(n) to check whether value is passed or not. The value is not passing from the onBlur event. The alert message displays ‘undefined’.
How to get rid of this issue?
remove onBlur from your aspx template file. Just leave one you have added from code-behind. and it will work.