我在 asp.net 网页中有一个文本框。在回发的情况下,我需要将焦点设置在此文本框中的最后一个字符上。我如何在不使用 jQueries 之类的情况下使用 c# 执行此操作。 谢谢
最佳答案
这是 Use JavaScript to place cursor at end of text in text input element 中提出的解决方案的变体。 :
void btnPostBack_Click(object sender, EventArgs e)
{
txtFocus.Attributes["onfocus"] = "var value = this.value; this.value = ''; this.value = value; onfocus = null;";
txtFocus.Focus();
}
关于c# - 使用 C# 在 asp.net 网页的最后一个字符中将焦点设置在文本框中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36793112/