简体   繁体   中英

Griview Textbox textchanged event not firing

I've a Gridview with textbox having id gdtxtPayingamount.I've used textchanged event.

In normal case its works fine.

But I've used a javascript function for checking numbers only in the textbox.Javascript works fine and it shows alert when a string is entered.The problem is when number is entered, textchanged event is not firing

Javascript is as follows

function CheckNumbers(objRef)
{        
    if(isNaN(objRef.value))
    {
        alert('Enter number only');
        objRef.value="";
        return false;
    }
    else
    {
        return true;
    }

}

I've called this javascript in gridview rowcreated event

protected void gdMainDetails_RowCreated(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {

            TextBox txt = (TextBox)e.Row.FindControl("gdtxtPayingAmount");
            txt.Attributes.Add("onkeyup", "return CheckNumbers(" + txt.ClientID + ")");

    }
}

Javascript works fine and it shows alert when a string is entered.The problem is when number is entered textchanged event is not firing

如果isNaN(objRef.value)== false在JS函数中返回true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM