Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
2.00/5 (3 votes)
See more:
C#
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..
Posted
Updated 10-May-17 5:15am
v2
Comments
vinay.tatipamula 11-Sep-13 6:40am    
You should write a webmethod or pagemethod and call that method using ajax or jquery.. u can not call a c#fucntion as a javascript function as you expected...

1 solution

C#
lblcolorname.Attributes.Add("onmouseover", "imgcalal()");
//adding attribute to label

JavaScript
public void imgcalal()
{
document.getElementById('you imagebuttonid').click();
//we are firing click event of image button
}

C#
<asp:imagebutton id="imagebutton" onclick="btnsearch_Click" />
//html image button have already defined c# function onclick


C#
protected void btnsearch_Click(object sender, EventArgs e)
   {

// this will be executed
}


regards..:)
 
Share this answer
 
v3
Comments
Thanks7872 11-Sep-13 6:56am    
What is lblcolorname? Why imagebutton? What is btnSearch?
Dholakiya Ankit 11-Sep-13 7:00am    
lblcolor name is label and image button is button and btnsearch is click event of that one
Thanks7872 11-Sep-13 7:03am    
dholakiya ankit wrote:
lblcolor name is label.

Who said this?
Dholakiya Ankit 11-Sep-13 7:13am    
i guess rohan and entry has excepted answer i see his posts regularly and he have similar method like this one
Thanks7872 11-Sep-13 7:56am    
What you mean by now get it? Don't assume anything by yourself. If the question is clear for you two only,that won't make any sense. Forum is not meant to resolve problems of OP only,its for everyone.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900