如何为保持光标位置的触摸屏应用程序制作数字小键盘? [英] How do I make numeric keypad for a touch screen application that maintains its cursor position?

查看:138
本文介绍了如何为保持光标位置的触摸屏应用程序制作数字小键盘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#和ASP.NET制作触摸屏的数字小键盘,允许用户输入大小为4的针脚号码进行登录。

当用户触摸特定号码时,它应该出现在文本框中但作为*。为此,我使用隐藏字段跟踪用户输入的数字,并在文本框中每次用户触摸任何数字时都显示a *。

我想要的是保持光标位置根据条目移动。

一切正常,但我需要保持光标位置。



这是代码时按下7:

I am making a numeric keypad for touch screen using C# and ASP.NET, allowing an user to enter the pin number of size 4 for login.
When the user touches on a particular number, it should appear in a text box but as a *. For this, I have used hidden field that tracks number entered by user and in the text box a * is shown every time the user touches any number.
What I would like is that the cursor position is maintained and is moved according the entry.
Everything works fine but I need the cursor position to be maintained in it.

Here is code when 7 is pressed:

protected void lnkNumberPadSeven_Click(object sender, EventArgs e)
  {
      string num = lnkNumberPadSeven.CommandArgument;
      if (txtPassword.Text.Length <= 3)
      {
          txtPassword.Text = string.Concat(Server.HtmlEncode(txtPassword.Text.ToString()), "*");
          hdnPassword.Value = string.Concat(hdnPassword.Value, num);
      }
  }



任何人都可以帮忙.. ??


Can anyone help.. ??

推荐答案

最简单办法?不要自己更换!如果将TextBox.UseSystemPassword属性设置为true,它将为您执行此操作。或者,如果你必须使用*字符,那么将UseSystemPassword保留为false,将TextBox.Password Char设置为'*',它将使用它。



如果你真的,真的,必须自己做,那么我认为你真正想做的只是添加一行:

Easiest way? Don't replace it yourself! If you set the TextBox.UseSystemPassword property to true, it will do it for you. Or, if you must use "*" characters, then leave UseSystemPassword at false, as set TextBox.Password Char to '*' and it will use that instead.

If you really, really, must do it yourself, then I think what you really want to do is just add the line:
txtPassword.Focus();

上面的方法。


这篇关于如何为保持光标位置的触摸屏应用程序制作数字小键盘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆