how to call the c# function on mouse over

Posted by Rajass22 under ASP.NET on 9/11/2013 | Points: 10 | Views : 9620 | Status : [Member] | Replies : 2
HI,


lblcolorname.Attributes.Add("onmouseover", "imgcalal()");

public void imgcalal()
{

}

In c# asp.net i want to call the c# function like above. But it's not working.

THanks in advance..




Responses

Posted by: Bandi on: 9/11/2013 [Member] [MVP] Platinum | Points: 25

Up
0
Down
refer this link
http://bytes.com/topic/asp-net/answers/863164-how-make-mouse-over-event-asp-net
http://stackoverflow.com/questions/6079480/call-code-behind-method-from-aspx-page
http://meeraacademy.com/javascript/display-text-on-label-control-while-onmouseover-on-image-in-asp-net/

If you wish to call C# method for OnMouseOver event of the control then
call method name inside the eventMethod()
public void ControlName_EventName()

{
Call C# method
}


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Rajass22, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Allemahesh on: 9/11/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
Dear Rajass,

This is good questions.
But Attributes.Add() methods should not work on label control.

But there is alternative way to do this:-

1. Create a LinkButton control on page and covert this to normal text format using css.
<asp:LinkButton ID="LinkButton1" Style="color: #000; text-decoration: none; cursor: text;"

runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton>

2. Now change the c# code as below:-
protected void Page_Load(object sender, EventArgs e)

{
LinkButton1.Attributes.Add("onmouseover", "this.click()");
}

protected void LinkButton1_Click(object sender, EventArgs e)
{
Response.Write("it works"); //Here you can write your own code.
}


Happy Coding.

If it helps you or directs U towards the solution, MARK IT AS ANSWER

Rajass22, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response