Hi TS,
Thanks for your post.
Based on my understanding, you want to get the function that: when the user
hits enter key in the textbox, just trigger the server side Button's Click
event.
To achieve this, we have to do some customization at the client side. We
can use javascript to cancel the current enter key press operation, then
programmatically invoke the button.click() method. Also, we can first
associate the client textbox.onkeypress event with the client javascript
code. Below is the demo code:
private void Page_Load(object sender, System.EventArgs e)
{
this.TextBox1.Attributes.Add("onkeypress","button_ click()");
}
<script language="javascript">
function button_click()
{
if(window.event.keyCode==13)
{
var Button1=document.getElementById("Button1");
Button1.click();
window.event.cancel=true;
}
}
</script>
This code works well on my side. Hope it helps
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! -
www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.