中继器中的asp.net imagebutton [英] asp.net imagebutton in repeater

查看:76
本文介绍了中继器中的asp.net imagebutton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

..我在HeadeTemplate内有一个图像按钮,当我单击该按钮时,不会触发click事件.但是只要它不在HeaderTemplate中,就会触发该事件.请帮忙!真烦人!

我的代码如下:

Hi guy..i have an image button that is is inside a HeadeTemplate, and when i click the button the click event does not fire..but as soon as it is out of the HeaderTemplate then the event gets fired..please help! Its really annoying!

My code is as follows:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ResultsControl.ascx.cs"
    Inherits="Web.Campaign.Controls.ResultsControl"%>
<asp:UpdatePanel ID="upResults" runat="server">
    <contenttemplate>
    
        <div id="divResultsMain">
            <br />
            <asp:Repeater ID="repeaterCampaignList" runat="server">
                <HeaderTemplate>
                    <table cellspacing="0" cellpadding="0">
                        <tr class="repeaterAlternatingItem">
                            <th>
                                <asp:ImageButton ID="campNameAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                    Height="20px" Width="20" OnClick="campNameAsc_Click" CausesValidation="false"/>
                                <asp:ImageButton ID="campNameDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                    Height="20px" Width="20" OnClick="campNameDesc_Click" CausesValidation="true" />Campaign
                                Name
                            </th>
                            <th>
                                <asp:ImageButton ID="campIDAsc" runat="server" ImageUrl="~/images/up-arrow.jpg" Height="20px"
                                    Width="20" OnClick="campIDAsc_Click" />
                                <asp:ImageButton ID="campIDDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                    Height="20px" Width="20" OnClick="campIDDesc_Click" />Campaign ID
                            </th>
                            <th>
                                <asp:ImageButton ID="campTypeAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                    Height="20px" Width="20px" OnClick="campTypeAsc_Click" />
                                <asp:ImageButton ID="campTypeDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                    Height="20px" Width="20" OnClick="campTypeDesc_Click" />
                                Campaign Type
                            </th>
                            <th style="width:43px">
                             <asp:ImageButton ID="VIPAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                    Height="20px" Width="20" OnClick="campNameAsc_Click" ImageAlign="NotSet" />
                                <asp:ImageButton ID="VIPDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                    Height="20px" Width="20" OnClick="campNameDesc_Click" CausesValidation="False" />
                                VIP
                            </th>
                            <th>
                             <asp:ImageButton ID="countryAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                    Height="20px" Width="20" OnClick="campNameAsc_Click"/>
                                <asp:ImageButton ID="countryDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                    Height="20px" Width="20" OnClick="campNameDesc_Click" CausesValidation="False" />
                                Country
                            </th>
                            <th>
                             <asp:ImageButton ID="brandAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                    Height="20px" Width="20" OnClick="campNameAsc_Click" />
                                <asp:ImageButton ID="brandDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                    Height="20px" Width="20" OnClick="campNameDesc_Click" CausesValidation="False" />
                                Brand
                            </th>
                            <th>
                             <asp:ImageButton ID="activeAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                    Height="20px" Width="20" OnClick="activeAsc_Click" />
                                <asp:ImageButton ID="activeDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                    Height="20px" Width="20" OnClick="activeDesc_Click" CausesValidation="False" />
                                Active
                            </th>
                            <th>
                                <asp:ImageButton ID="createdByAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                    Height="20px" Width="20px" OnClick="createdByAsc_Click" />
                                <asp:ImageButton ID="createdByDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                    Height="20px" Width="20" OnClick="createdByDesc_Click" />
                                Created By
                            </th>
                            <th>
                                <asp:ImageButton ID="campStartAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                    Height="20px" Width="20px" OnClick="campStartAsc_Click" />
                                <asp:ImageButton ID="campStartDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                    Height="20px" Width="20" OnClick="campStartDesc_Click" />
                                Campaign Start Date
                            </th>
                            <th>
                                <asp:ImageButton ID="campEndAsc" runat="server" ImageUrl="~/images/up-arrow.jpg"
                                    Height="20px" Width="20px" OnClick="campEndAsc_Click" />
                                <asp:ImageButton ID="campEndDesc" runat="server" ImageUrl="~/images/down-arrow.jpg"
                                    Height="20px" Width="20" OnClick="campEndDesc_Click" />
                                Campaign End Date
                            </th>
                        </tr>
                </HeaderTemplate>
                <itemtemplate>
                    <tr class="repeaterItem">
                        <td>
                            <%#DataBinder.Eval(Container.DataItem, "StoreDescription")%>
                        </td>
                        <td>
                            <%#DataBinder.Eval(Container.DataItem, "ID") %>
                        </td>
                        <td>
                            <%#DataBinder.Eval(Container.DataItem, "CampaignType")%>
                        </td>
                        <td align="center">
                            <asp:CheckBox runat="server" Enabled="false" Checked=''<%#DataBinder.Eval(Container.DataItem, "IsVIP")%>'' />
                        </td>
                        <td>
                            <%#DataBinder.Eval(Container.DataItem, "Country")%>
                        </td>
                        <td>
                            <%#DataBinder.Eval(Container.DataItem, "Brand")%>
                        </td>
                        <td align="center">
                            <asp:CheckBox ID="CheckBox1" Enabled="false" runat="server" Checked=''<%#DataBinder.Eval(Container.DataItem, "IsActive")%>'' />
                        </td>
                        <td>
                            <%#DataBinder.Eval(Container.DataItem, "Owner")%>
                        </td>
                        <td>
                            <%#DataBinder.Eval(Container.DataItem, "CampaignStartDate", "{0 : dd MMMM yyyy}")%>
                        </td>
                        <td>
                            <%#DataBinder.Eval(Container.DataItem, "CampaignEndDate", "{0 : dd MMMM yyyy}")%>
                        </td>
                    </tr>
                </itemtemplate>
                <alternatingitemtemplate>
                    <tr class="repeaterAlternatingItem">
                        <td>
                            <%#DataBinder.Eval(Container.DataItem, "StoreDescription")%>
                        </td>
                        <td>
                            <%#DataBinder.Eval(Container.DataItem, "ID") %>
                        </td>
                        <td>
                            <%#DataBinder.Eval(Container.DataItem, "CampaignType")%>
                        </td>
                        <td align="center">
                            <asp:CheckBox Enabled="false" runat="server" Checked=''<%#DataBinder.Eval(Container.DataItem, "IsVIP")%>'' />
                        </td>
                        <td>
                            <%#DataBinder.Eval(Container.DataItem, "Country")%>
                        </td>
                        <td>
                            <%#DataBinder.Eval(Container.DataItem, "Brand")%>
                        </td>
                        <td align="center">
                            <asp:CheckBox ID="CheckBox1" Enabled="false" runat="server" Checked=''<%#DataBinder.Eval(Container.DataItem, "IsActive")%>'' />
                        </td>
                        <td>
                            <%#DataBinder.Eval(Container.DataItem, "Owner")%>
                        </td>
                        <td>
                            <%#DataBinder.Eval(Container.DataItem, "CampaignStartDate","{0 : dd MMMM yyyy}")%>
                        </td>
                        <td>
                            <%#DataBinder.Eval(Container.DataItem, "CampaignEndDate", "{0 : dd MMMM yyyy}")%>
                        </td>
                    </tr>
                </alternatingitemtemplate>
                <footertemplate>
                    </footertemplate></table>
                
            
        </div>
        <p>
             <p>
                <asp:Label ID="lblCurrentPage" runat="server">
            </p>
            <asp:LinkButton ID="prev" runat="server" onclick="prev_Click">Prev
            <asp:LinkButton ID="next" runat="server" onclick="next_Click">Next
            <p>
            </p>
        </p>
    </contenttemplate>

推荐答案

尝试为该按钮指定命令名称.并访问它或从转发器的itembound事件中编写相关事件代码.
Try to give a command name to that button. and access it or write relevent code from repeater`s itembound event.


这篇关于中继器中的asp.net imagebutton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆