【问题标题】:How can I set the cursor position in a WebControl textbox in ASP.NET?如何在 ASP.NET 的 WebControl 文本框中设置光标位置?
【发布时间】:2015-04-11 17:57:32
【问题描述】:

我需要将光标设置到 webcontrol 文本框的末尾。我该怎么做?

【问题讨论】:

    标签: c# asp.net textbox web-controls


    【解决方案1】:

    您只能使用 JavaScript.on 页面加载事件来做到这一点。只需通过提供文本框的 id 将此代码添加到您的部分中

    <script type="text/javascript">
    window.onload = function() {
        var oInput = document.getElementById("<%=TextBox1.ClientID%>");
        oInput.focus();    
        oInput.value += "";
    };
    </script>
    

    【讨论】:

    • 您能否更具体地说明如何操作、重命名什么以及在哪里重命名,因为我是 ASP.NET 的新手,而且我根本不熟悉 javascript。
    猜你喜欢
    • 1970-01-01
    • 2015-04-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多