gpt4 book ai didi

c# - 使用 C# 在 asp.net 网页的最后一个字符中将焦点设置在文本框中

转载 作者:太空宇宙 更新时间:2023-11-03 23:17:24 25 4
gpt4 key购买 nike

我在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com