简体   繁体   English

定位标记Onserverclick事件

[英]Anchor tag Onserverclick event

Trying to implement server side click to anchor tag Below code is in .CS file(sharepoint 2007/c#) 尝试实现服务器端单击以锚定标签下面的代码在.CS文件中(sharepoint 2007 / c#)

lblDetails.Text += userCreds[i].UserInfoID + " - " + "[a href='#' runat ='server' onserverclick='LinkButton_Click ]+ userCreds[i].AccountName + "[/a] ";

public void LinkButton_Click(object sender, EventArgs e)
{}

when cliking on link it is not going to LinkButton_clicked menthod 当点击链接时,它不会链接到LinkBut​​ton_clicked方法

Please help !!! 请帮忙 !!!

尝试使用如下所示的委托/事件处理程序挂接事件,而不是使用onserverclick标记注入事件。

lblDetails.Click += new EventHandler(LinkButton_Click);

See if this works: 查看是否可行:

  • Add a button that will do the action normally eg btnLinkButton 添加一个将正常执行操作的按钮,例如btnLinkBut​​ton

  • Register the event handler: 注册事件处理程序:

    btnLinkButton.Click += new EventHandler(LinkButton_Click);

  • Add an event to the label 将事件添加到标签

lblDetails.Attributes.Add("onclick", ClientScript.GetPostBackEventReference(btnLinkButton, null))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM