jQuery触发器点击aspx页面不起作用

时间:2012-01-20 15:22:15

标签: jquery vb.net triggers clientscriptmanager

我的ASPX标记如下

<a id="lnkLogin" href="javascript:__doPostBack('ctl00$LoginReg1$lnkLogin','')">Login</a>

我的功能如下

function LogOut() {
        $("#lnkLogin").trigger('click');
    }

由于某种原因,这个触发点击不起作用?

我也尝试过这样的代码,就像这样

If Request.UrlReferrer IsNot Nothing AndAlso Request.UrlReferrer.AbsoluteUri.Contains("32088") Then

        ' Define the name and type of the client script on the page. 
        Dim csName As [String] = "ButtonClickScript"
        Dim csType As Type = Me.[GetType]()

        ' Get a ClientScriptManager reference from the Page class. 
        Dim cs As ClientScriptManager = Page.ClientScript

        ' Check to see if the client script is already registered. 
        If Not cs.IsClientScriptBlockRegistered(csType, csName) Then
            Dim csText As New StringBuilder()
            csText.Append("<script type=""text/javascript""> function LogOut() {")
            csText.Append("$('#lnkLogin').trigger('click');} </")
            csText.Append("script>")
            cs.RegisterClientScriptBlock(csType, csName, csText.ToString())
        End If
    End If

但不能使用

1 个答案:

答案 0 :(得分:0)

试试这个

function LogOut() {
    $("#lnkLogin")[0].click();
}