Hi,
We're experiencing strange behavior in one of our pages. When we put a cursor in any of the Search fields and press Enter button, the Logout fires and the Login page displays. I would prefer Enter to fire Search button click, or do it only after I entered at least one character in the Search fields (otherwise don't do anything).
We have a similar page in our application, where the JavaScript code is added in the Load method of the page using ClientScriptManager.RegisterStartuptScript method. This JavaScript checks for the Enter key
Then in OnPreRender event for the textboxes the OnKeyChange attribute is added to call this function.
This code works fine in one of the pages. However, I tried to implement the same logic for another page and OnPreRender never fires.
Do you have ideas how to fix the problem and how to stop Logout code firing by pressing Enter?
Thanks.
We're experiencing strange behavior in one of our pages. When we put a cursor in any of the Search fields and press Enter button, the Logout fires and the Login page displays. I would prefer Enter to fire Search button click, or do it only after I entered at least one character in the Search fields (otherwise don't do anything).
We have a similar page in our application, where the JavaScript code is added in the Load method of the page using ClientScriptManager.RegisterStartuptScript method. This JavaScript checks for the Enter key
Code:
string Script = @"<script language=""javascript"">
// make sure that when enter clicked click event fired.
function testEnterKey(event)
{
if (event.keyCode == 13)
{
var btnSearch = document.getElementById('" + this.btnSearch.ClientID + @"');
event.cancelBubble = true;
event.returnValue = false;
btnSearch.click();
}
}
</script>";
Then in OnPreRender event for the textboxes the OnKeyChange attribute is added to call this function.
This code works fine in one of the pages. However, I tried to implement the same logic for another page and OnPreRender never fires.
Do you have ideas how to fix the problem and how to stop Logout code firing by pressing Enter?
Thanks.