Posted: 7/8/2011
I am working on a Web POS system. One of the clients requirements is that there is no key board at the terminal. I still need to manage users and roles. I made a web keypad for the input with the mouse. On page load I set focus to UserName Textbox and inputting of letters work fine with the code I am using. I wanted to use only numbers for the password. I used the same code but it doesn't work. I evern set focus to the Password Textbox first but still doesn't work.
Here is the code for setting focus to the UserName Textbox and what I used for the "Letter" buttons:
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Login Login1 = (Login)FindControl("Login1"); if (Login1 != null) { TextBox tb = (TextBox)Login1.FindControl("UserName"); if (tb != null) { tb.Focus(); } } } } protected void Button13_Click(object sender, EventArgs e) { Login Login1 = (Login)FindControl("Login1"); if (Login1 != null) { TextBox tb1 = (TextBox)Login1.FindControl("UserName"); if (tb1 != null) { tb1.Text += "w"; } } } protected void Button14_Click(object sender, EventArgs e) { Login Login1 = (Login)FindControl("Login1"); if (Login1 != null) { TextBox tb1 = (TextBox)Login1.FindControl("UserName"); if (tb1 != null) { tb1.Text += "e"; } } }
I repeated the button click events in the same manner for all the letters.
The Enter Password button sets the focus on the Password Textbox(which works fine)
I used basically the same code for the numbers but it doesn't work at all.
protected void Button39_Click(object sender, EventArgs e) { Login Login1 = (Login)FindControl("Login1"); if (Login1 != null) { TextBox tb2 = (TextBox)Login1.FindControl("Password"); if (tb2 != null) { tb2.Focus(); } } } protected void Button2_Click(object sender, EventArgs e) { Login Login1 = (Login)FindControl("Login1"); if (Login1 != null) { TextBox tb2 = (TextBox)Login1.FindControl("Password"); if (tb2 != null) { tb2.Text += "1"; } } } protected void Button3_Click(object sender, EventArgs e) { Login Login1 = (Login)FindControl("Login1"); if (Login1 != null) { TextBox tb2 = (TextBox)Login1.FindControl("Password"); if (tb2 != null) { tb2.Text += "2"; } } }