Click here to Skip to main content
15,895,777 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
On click of a td inside a table row I want to raise an event. I used the following code but doesnt work.

What I have tried:

HTML
<td onclick="button87()" style="font-size:medium; background-color:InfoBackground;">


C#
public void button87()

{..}
Posted
Updated 29-Jul-16 2:18am
Comments
Karthik_Mahalingam 29-Jul-16 6:45am    
onclick will not call the server event, better write a javascript method and call server method using ajax.
S.Rajendran from Coimbatore 1-Aug-16 3:56am    
I tried with the following. Not working. Even it not reaches the breakpoint at code.

<script type="text/javascript">
function progressiveTd() { Panel5.Visible = true;.....}
</script>
<td id="progressiveTd" onclick="progressiveTd_Click"..

in code:
protected void progressiveTd_Click(object sender, EventArgs e)
{
ScriptManager.RegisterClientScriptBlock(this, GetType(), "", "progressiveTd();", true);

}



[no name] 29-Jul-16 7:01am    
Hi Bro,
Check below link

HI friend below link help to you.

Edit fiddle - JSFiddle[^]
 
Share this answer
 
Comments
ZurdoDev 29-Jul-16 8:03am    
I voted 4. Instead of just posting a link to a page, I suggest you also post the code in your solution and explain it.
That is because you are trying to connect the client-side scripts to your server-side scripts — while that is possible through Ajax requests, this is not going to work. What you should have done is, created a JavaScript function on the client-side and used that to handle the event.
JavaScript
function button87 () {
   // Code to execute here.
}

This will be executed one your table description cell gets a click on it. Note that, attaching a server-side event was done in ASP.NET Web Forms where you also had set runat="server" attribute to the elements. ASP.NET would then process the element on the server-side instead of the client-side. But if you are processing the element and handling the events on the client-side, you must write JavaScript (client-side) code to handle them too.

I have trusted MDN documentations for these years and I would recommend the same to you, DOM on-event handlers - Web developer guides | MDN[^]
 
Share this answer
 

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