Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/338.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.NET+C+jQuery:单击作为div的datalistItem,然后会触发ItemCommand事件吗?_C#_Asp.net_Jquery - Fatal编程技术网

C# ASP.NET+C+jQuery:单击作为div的datalistItem,然后会触发ItemCommand事件吗?

C# ASP.NET+C+jQuery:单击作为div的datalistItem,然后会触发ItemCommand事件吗?,c#,asp.net,jquery,C#,Asp.net,Jquery,我有这样一个数据列表: <asp:DataList ID="DataList_Trips" OnItemCommand="DataList_Trips_ItemCommand" > <ItemTemplate> <div class="divListTrips"> </div> </ItemTemplate> </asp:DataList> 当我使用divListTrips类

我有这样一个数据列表:

<asp:DataList ID="DataList_Trips" OnItemCommand="DataList_Trips_ItemCommand" >
    <ItemTemplate>
        <div class="divListTrips">
        </div>
    </ItemTemplate>
</asp:DataList>

当我使用divListTrips类单击div时,是否有可能触发事件OnItemCommand?

我建议使用jQuery调用page方法,如示例中所示


与其试图强制它,不如调用ItemCommand处理程序。

你的OnItemCommand事件在做什么?回发?页面方法始终是静态的。在我的项目中,这不是一个好的选择。无论如何,谢谢你。我想我应该把div的所有文本包装在一个linkButton中,这也是一个好主意!这可能会起作用,但将DIV放在标记中是不符合要求的。如果页面方法不是一个好的选择,您可以通过向页面传递action querystring参数来实现类似的行为。在OnLoad方法中,检查action参数并执行所需的行为。如果没有action参数,请执行正常的页面加载行为。