猿问

如何甚至在 ASP 中的表上添加 onclick 以便您可以从 c# 后端执行某些操作

我有这段代码


<asp:Table ID="Table1" runat="server">

    <asp:TableRow>

        <asp:TableCell>

         Cell text

        </asp:TableCell>

    </asp:TableRow>

</asp:Table>

我想要做的是使这个表 clicable 并在后面处理一些东西,例如


void Table1_Click(Object sender, EventArgs e)

{

    //do somthing

 }


泛舟湖上清波郎朗
浏览 169回答 3
3回答

慕田峪9158850

`在jQuery中:$(document).ready(function(){$("#Table1").on('click',function(){警报();&nbsp;});&nbsp;});`

汪汪一只猫

您可以使用 LinkButton 包装整个 Table。<asp:LinkButton ID="LinkButton1" runat="server" OnClick="Button1_Click">&nbsp; &nbsp; <asp:Table ID="Table1" runat="server">&nbsp; &nbsp; &nbsp; &nbsp; <asp:TableRow>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <asp:TableCell>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Cell text&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </asp:TableCell>&nbsp; &nbsp; &nbsp; &nbsp; </asp:TableRow>&nbsp; &nbsp; </asp:Table></asp:LinkButton>
随时随地看视频慕课网APP
我要回答