我的 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
但不使用