onclick table TD

onclick for table TD

正在尝试为 <td> 执行 onClick JS 函数。

<td id="Td10" runat="server" onclick="doPostBack('<%#Eval("ID")%>')">                                      </td>

标记为

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: The server tag is not well formed.

但是我看不出格式不正确是怎么回事?

有什么建议吗?

我从以下位置获得了这个例子:

Table row onclick event that runs codebehind

--包含在编辑中---

 <script type="text/javascript">
        function doPostBack(id) {
           alert("MAP ID is " + id);
        }
</script>

控制台在

中抛出错误 'UNEXPECTED TOKEN <'
<td id="MainContent_lvDataStores_Td10_0" onclick="doPostBack(&lt;%#Eval(&quot;ID&quot;)%>)">

它删除 < 并包含

替换为:-

<td id="Td10" runat="server" onclick="doPostBack('<%#Eval("ID")%>')"> 

与:-

<td id="Td10" runat="server" onclick='<%#"doPostBack("+Eval("ID")+")" %>'></td>

希望对您有所帮助。