Reputation: 47
Is it possible to add an onClick event to an asp:label and let it call a c# method rather than js? Something like:
<asp:Label
ID="lblTest"
runat="server"
Text=""
ToolTip="Amount of errors this person is processing"
Style="cursor: help;"
OnClick="lbl_Click"
/>
And on the server side:
protected void lbl_Click(object sender, EventArgs e)
{
lblTest.Text = "Clicked"
}
Upvotes: 1
Views: 6920
Reputation: 172448
You can create linkedbutton and make it look like label using CSS like this:
<asp:LinkButton ID="LinkButton1"
runat="server"
CssClass="myclass"
OnClick="LinkButton1_Click">
MyButton
</asp:LinkButton>
and in CSS
a.myclass{ color: #000000; text-decoration: none; }
a.myclass:hover { text-decoration: none; }
and then call it like
public void LinkButton1_Click()
{
lblTest.Text = "Clicked"
}
Upvotes: 2