CTextBox.NextFocusOnEnter: Point to the next control to focus on Enter key.
This commit is contained in:
@@ -17,6 +17,8 @@ namespace VAR.Focus.Web.Controls
|
||||
|
||||
private bool _markedInvalid = false;
|
||||
|
||||
private Control _nextFocusOnEnter = null;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
@@ -45,6 +47,12 @@ namespace VAR.Focus.Web.Controls
|
||||
set { _markedInvalid = value; }
|
||||
}
|
||||
|
||||
public Control NextFocusOnEnter
|
||||
{
|
||||
get { return _nextFocusOnEnter; }
|
||||
set { _nextFocusOnEnter = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Control life cycle
|
||||
@@ -72,6 +80,14 @@ namespace VAR.Focus.Web.Controls
|
||||
Attributes.Add("placeholder", _placeHolder);
|
||||
}
|
||||
|
||||
if (_nextFocusOnEnter!=null)
|
||||
{
|
||||
this.Attributes.Add("onkeydown", String.Format(
|
||||
"if(event.keyCode==13){{document.getElementById('{0}').focus(); return false;}}",
|
||||
_nextFocusOnEnter.ClientID));
|
||||
}
|
||||
|
||||
|
||||
// FIX: The framework deletes textbox values on password mode
|
||||
if (TextMode == TextBoxMode.Password)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,6 @@ namespace VAR.Focus.Web.Pages
|
||||
|
||||
void FrmBoard_Init(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
string strIDBoard = GetRequestParm(Context, "idBoard");
|
||||
if (String.IsNullOrEmpty(strIDBoard) == false)
|
||||
{
|
||||
|
||||
@@ -57,9 +57,11 @@ namespace VAR.Focus.Web.Pages
|
||||
Controls.Add(lblTitle);
|
||||
|
||||
Controls.Add(FormUtils.CreateField("Name/Mail", _txtNameEmail));
|
||||
_txtNameEmail.NextFocusOnEnter = _txtPassword;
|
||||
_txtNameEmail.PlaceHolder = "Name/Mail";
|
||||
|
||||
Controls.Add(FormUtils.CreateField("Password", _txtPassword));
|
||||
_txtPassword.NextFocusOnEnter = _btnLogin;
|
||||
_txtPassword.PlaceHolder = "Password";
|
||||
|
||||
Controls.Add(FormUtils.CreateField(String.Empty, _btnLogin));
|
||||
@@ -67,11 +69,6 @@ namespace VAR.Focus.Web.Pages
|
||||
_btnLogin.Click += btnLogin_Click;
|
||||
|
||||
Controls.Add(FormUtils.CreateField(String.Empty, new HyperLink { Text = "Register user", NavigateUrl = "FrmRegister" }));
|
||||
|
||||
_txtNameEmail.Attributes.Add("onkeydown", String.Format(
|
||||
"if(event.keyCode==13){{document.getElementById('{0}').focus(); return false;}}", _txtPassword.ClientID));
|
||||
_txtPassword.Attributes.Add("onkeydown", String.Format(
|
||||
"if(event.keyCode==13){{document.getElementById('{0}').focus(); return false;}}", _btnLogin.ClientID));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -81,15 +81,19 @@ namespace VAR.Focus.Web.Pages
|
||||
Controls.Add(_pnlRegister);
|
||||
|
||||
_pnlRegister.Controls.Add(FormUtils.CreateField("Name", _txtName));
|
||||
_txtName.NextFocusOnEnter = _txtEmail;
|
||||
_txtName.PlaceHolder = "Name";
|
||||
|
||||
_pnlRegister.Controls.Add(FormUtils.CreateField("Email", _txtEmail));
|
||||
_txtEmail.NextFocusOnEnter = _txtPassword1;
|
||||
_txtEmail.PlaceHolder = "Email";
|
||||
|
||||
_pnlRegister.Controls.Add(FormUtils.CreateField("Password", _txtPassword1));
|
||||
_txtPassword1.NextFocusOnEnter = _txtPassword2;
|
||||
_txtPassword1.PlaceHolder = "Password";
|
||||
|
||||
_pnlRegister.Controls.Add(FormUtils.CreateField(String.Empty, _txtPassword2));
|
||||
_txtPassword2.NextFocusOnEnter = _btnRegister;
|
||||
_txtPassword2.PlaceHolder = "Password";
|
||||
|
||||
_btnRegister.Text = "Register";
|
||||
@@ -102,17 +106,7 @@ namespace VAR.Focus.Web.Pages
|
||||
pnlButtons.Controls.Add(_btnRegister);
|
||||
pnlButtons.Controls.Add(_btnExit);
|
||||
_pnlRegister.Controls.Add(FormUtils.CreateField(String.Empty, pnlButtons));
|
||||
|
||||
_txtName.Attributes.Add("onkeydown", String.Format(
|
||||
"if(event.keyCode==13){{document.getElementById('{0}').focus(); return false;}}", _txtEmail.ClientID));
|
||||
_txtEmail.Attributes.Add("onkeydown", String.Format(
|
||||
"if(event.keyCode==13){{document.getElementById('{0}').focus(); return false;}}", _txtPassword1.ClientID));
|
||||
_txtPassword1.Attributes.Add("onkeydown", String.Format(
|
||||
"if(event.keyCode==13){{document.getElementById('{0}').focus(); return false;}}", _txtPassword2.ClientID));
|
||||
_txtPassword2.Attributes.Add("onkeydown", String.Format(
|
||||
"if(event.keyCode==13){{document.getElementById('{0}').focus(); return false;}}", _btnRegister.ClientID));
|
||||
|
||||
|
||||
|
||||
Controls.Add(_pnlSuccess);
|
||||
_pnlSuccess.Visible = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user