سؤال

I have a SharePoint solution with a link and a C# method. There is any way I can access the C# method from the a tag:

<a href="#" runat="server" onclick="MyFunction()">CLICK</a>
public void MyFunction()
{

}
هل كانت مفيدة؟

المحلول

<a href="#" runat="server" onclick="MyFunction()">CLICK</a>
<script type="text/javascript">
public void MyFunction()
{
      var temp = '<%=CodeBehindMethod()%>';
}
</script> 

Code Behind Method

public void CodeBehindMethod() 
{
      //Your code goes here
}

نصائح أخرى

You can use a LinkButton and use its onClick event:

<asp:LinkButton Text="CLICK" OnClick="MyFunction()" runat="server"/>

and in the code behind use

public void MyFunction(Object sender, EventArgs e) 
{

}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top