Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In the below code snippet onChange event is not working if I am pressing 'enter' after putting details in the text box. But the event is working correctly if I m clicking on the page after entering the details in the textbox.

s=s&"<input type=""text"" name=""xyz"" size=""1"" önChange=""return abc(this.form,1)"" value=" & pageno &" style=""border: 1px solid #C0C0C0; padding: 1; font-family:Arial; font-size:8pt"">

Thanks
Posted

Use EnterEvent to capture the event when enter is clicked and using JavaScript postback which uses the id value of the button which ll take u to the cs page

<asp:textbox id="TextBox1" clientidmode="Static" runat="server" onkeypress="return EnterEvent(event)" xmlns:asp="#unknown">

<asp:button id="Button1" runat="server" style="display:none" text="Button" xmlns:asp="#unknown">

XML
function EnterEvent(e) {
        if (e.keyCode == 13) {
            __doPostBack('<%=Button1.UniqueID%>', "");
        }
    }


C#
protected void Button1_Click(object sender, EventArgs e)
    {

    }
 
Share this answer
 
Thanks Arjun,
I used your suggestion in a different way and it worked. I used both onchange and onkeypressed event as below:

s=s&"<input type=""text"" name=""xyz"" size=""1"" önChange=""return abc(this.form,1)"" onkeypress=""xyz(e)"">

function xyz(a,e,1)
{
if(e.keyCode==13)
{
abc(a,1);
}
}
 
Share this answer
 
Comments
Arjun Holla 24-May-14 10:04am    
mark it as Accepted...If you find it helpfull

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900