数据列表中的图像按钮事件不起作用

发布于 2024-12-25 20:47:47 字数 2207 浏览 0 评论 0原文

图像按钮事件没有触发,我的代码中遗漏了一些东西吗 on itemcommand 事件未触发,请帮助我,我被困在其中 这是我的数据列表代码:

    <asp:DataList ID="DataList1" runat="server" RepeatColumns="1" 
    RepeatDirection="Vertical" Width="100%"
    onitemdatabound="DataList1_ItemDataBound" onitemcommand="DataList1_ItemCommand">
    <ItemTemplate>
    <div class="comments_pannel_top">
    <h2>Highly Recommended,</h2>
    <p>By:<a href="#"><asp:Label ID="lblCustomerName" runat="server"></asp:Label></a> – 
        <asp:Label ID="lblCity" runat="server"></asp:Label>, 
        <asp:Label ID="lblCountry" runat="server"></asp:Label> <span>
            <asp:Label ID="lblDate" runat="server"></asp:Label></span></p>
    </div>
    <div class="stars_1">
    <img src="images/favourities_icon.jpg" width="12" height="12" alt="" />
    <img src="images/favourities_icon.jpg" width="12" height="12" alt="" />
    <img src="images/favourities_icon.jpg" width="12" height="12" alt="" />
    <img src="images/favourities_icon.jpg" width="12" height="12" alt="" />
    <img src="images/favourities_icon.jpg" width="12" height="12" alt="" />
    </div>
    <div class="comment">
    <p><strong>5 out of 11 people found this review helpful.</strong></p>
    <p>
        <asp:Label ID="lblReview" runat="server"></asp:Label></p>
    </div>
    <div class="report_abuse">
    <p>Did you find this review helpful?</p>
    </div>

    <div class="comments_pannel_bottom">
    <div class="btns">
        <asp:ImageButton ID="btnYes" ImageUrl="images/yes_btn.jpg" width="33"   height="23"  runat="server" CommandName="Yes" />
        <asp:ImageButton ID="btnNo" runat="server" ImageUrl="images/no_btn.jpg" width="33" height="23" alt="" CommandName="No"/>

    </div>
    </div>
    </ItemTemplate>
</asp:DataList>

  This is the onitem command event handler:

  protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {

    }

the image button events are not firing am i missing something from my code
the on itemcommand event doesn't trigger please help me i'm stucked in it
this is my datalist code:

    <asp:DataList ID="DataList1" runat="server" RepeatColumns="1" 
    RepeatDirection="Vertical" Width="100%"
    onitemdatabound="DataList1_ItemDataBound" onitemcommand="DataList1_ItemCommand">
    <ItemTemplate>
    <div class="comments_pannel_top">
    <h2>Highly Recommended,</h2>
    <p>By:<a href="#"><asp:Label ID="lblCustomerName" runat="server"></asp:Label></a> – 
        <asp:Label ID="lblCity" runat="server"></asp:Label>, 
        <asp:Label ID="lblCountry" runat="server"></asp:Label> <span>
            <asp:Label ID="lblDate" runat="server"></asp:Label></span></p>
    </div>
    <div class="stars_1">
    <img src="images/favourities_icon.jpg" width="12" height="12" alt="" />
    <img src="images/favourities_icon.jpg" width="12" height="12" alt="" />
    <img src="images/favourities_icon.jpg" width="12" height="12" alt="" />
    <img src="images/favourities_icon.jpg" width="12" height="12" alt="" />
    <img src="images/favourities_icon.jpg" width="12" height="12" alt="" />
    </div>
    <div class="comment">
    <p><strong>5 out of 11 people found this review helpful.</strong></p>
    <p>
        <asp:Label ID="lblReview" runat="server"></asp:Label></p>
    </div>
    <div class="report_abuse">
    <p>Did you find this review helpful?</p>
    </div>

    <div class="comments_pannel_bottom">
    <div class="btns">
        <asp:ImageButton ID="btnYes" ImageUrl="images/yes_btn.jpg" width="33"   height="23"  runat="server" CommandName="Yes" />
        <asp:ImageButton ID="btnNo" runat="server" ImageUrl="images/no_btn.jpg" width="33" height="23" alt="" CommandName="No"/>

    </div>
    </div>
    </ItemTemplate>
</asp:DataList>

  This is the onitem command event handler:

  protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {

    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ゞ花落谁相伴 2025-01-01 20:47:47

它们绑定到什么服务器端事件处理程序?通常标记包含一个 OnCommand 属性,它将命令事件绑定到服务器端处理程序。 :

<asp:ImageButton id="imagebutton2" runat="server"
       AlternateText="Edit"
       ImageUrl="images/pict2.jpg"
       OnCommand="ImageButton_Command"
       CommandName="Edit"/>

请参阅此处的示例 OnCommand 属性的值将是服务器端事件处理程序方法的名称:

void ImageButton_Command(object sender, CommandEventArgs e) 
{
   //...
}

What server-side event handler are they bound to? Usually the markup contains an OnCommand property which binds the command event to a server-side handler. See examples here:

<asp:ImageButton id="imagebutton2" runat="server"
       AlternateText="Edit"
       ImageUrl="images/pict2.jpg"
       OnCommand="ImageButton_Command"
       CommandName="Edit"/>

The value for the OnCommand property would be the name of the server-side event handler method:

void ImageButton_Command(object sender, CommandEventArgs e) 
{
   //...
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文