Не могли бы вы попробовать добавить атрибуты во время выполнения, как это
Login loginControl = (Login)lvLoginView.FindControl("logLogin");
TextBox tbUserName = (TextBox)loginControl.FindControl("UserName");
TextBox tbPassword = (TextBox)loginControl.FindControl("Password");
Button loginButton = (Button)loginControl.FindControl("LoginButton");
tbUserName.Attributes["onKeyPress"] = "KeyDownHandler('" + loginButton.ClientID + "')";
tbPassword.Attributes["onKeyPress"] = "KeyDownHandler('" + loginButton.ClientID + "')";
и некоторые JS:
function KeyDownHandler(btn){
// process only the Enter key
if (event.keyCode == 13) {
// cancel the default submit
event.returnValue = false;
event.cancel = true;
var obj = document.getElementById(btn);
obj.click();
}}
ОБНОВЛЕНИЕ
Автопреобразован в VB.NET любезно предоставлен Telerik
Dim loginControl As Login = DirectCast(lvLoginView.FindControl("logLogin"), Login)
Dim tbUserName As TextBox = DirectCast(loginControl.FindControl("UserName"), TextBox)
Dim tbPassword As TextBox = DirectCast(loginControl.FindControl("Password"), TextBox)
Dim loginButton As Button = DirectCast(loginControl.FindControl("LoginButton"), Button)
tbUserName.Attributes("onKeyPress") = "KeyDownHandler('" + loginButton.ClientID + "')"
tbPassword.Attributes("onKeyPress") = "KeyDownHandler('" + loginButton.ClientID + "')"