0

I am creating several dynamic asp:Panels in asp:Lisview ItemTemplate. In panel there's a HTML table which is surrounded by link so the whole div/box is clickable. The problem is the linkbutton's OnClick event is not firing on server side. Any thoughts?

Here is the code:

              <asp:Panel runat="server" ClientIDMode="Static"> 
                <asp:LinkButton runat="server"  ID="Link" OnClick="Link_Click" CausesValidation="false">      
                    <table runat="server" id="Table" >            
                        <thead>
                            <tr><th colspan="3"><%#Eval("abc")%></th></tr>
                        </thead>
                        <tbody>

                             <tr>
                                <td >
                                    <asp:ImageButton runat="server"  ImageUrl="../Images/img_4.png"/>
                                </td>
                                <td runat="server" class="data" >
                                    <%#Eval("abc")%>
                                </td>

                                 <td>   
                                     04:15                                                                     
                                </td>

                            </tr>

                           </tbody> 
                    </table> 
                      </asp:LinkButton>
                  </asp:Panel> 

LinkClick Code

  protected void Link_Click(object sender, EventArgs e)
    {
        LinkButton link = (LinkButton)sender;
        String id = link.ID;

        if (id.StartsWith("T"))
            Response.Redirect("Time.aspx?Id=" + id);
        else
        {                
            Response.Redirect("Chart.aspx?Id=" + id);
        }
    }
AM0
  • 165
  • 2
  • 4
  • 20

1 Answers1

0

I figured it out. The asp:linkbutton id was being reset in the backend code and it was leading to broken link. That's why the click wouldn't work.

AM0
  • 165
  • 2
  • 4
  • 20