zoukankan      html  css  js  c++  java
  • ASP.net绑定文本框Enter事件到按钮 ASP.NET执行后台执行JS方法

    txtAccountBarcode.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('" + btnSearchN.UniqueID + "').click();return false;}} else {return true}; ")
     'To simplify the process to write javascript in vb code
        Public Sub CallJSFunction(ByVal strKey As String, ByVal strJScript As String)
            Me.Page.RegisterStartupScript(strKey, "<script language='javascript'>" + strJScript + "</script>")
        End Sub
    
        'To Set the focus to the specific control
        Public Sub SetFocus(ByVal strControlID As String)
            CallJSFunction("setFocus", "document.getElementById('" + strControlID + "').focus()")
            'CallJSFunction("setFocus", "document.getElementById('" + strControlID + "').select()")
        End Sub

    注:后台执行JS似乎只有在页面提交或刷新时才有作用,直接起效只有使用前台JS实现。

  • 相关阅读:
    Valid Anagram
    Spiral Matrix II
    Spiral Matrix
    Kth Smallest Element in a BST
    Count Primes
    javascript 判断浏览器
    javascript 数值交换技巧
    EntityFramework 6 分页模式
    JSON.parse 和 JSON.stringify
    CSS z-index
  • 原文地址:https://www.cnblogs.com/tylertang/p/3243194.html
Copyright © 2011-2022 走看看