Repeater中的ASP ImageButton没有触发

时间:2012-10-23 05:39:39

标签: asp.net postback repeater imagebutton

我有一个包含转发器的usercontrol。在这个转发器中有一个ImageButton,当点击它时应该调用expand方法。但是,ImageButton没有触发任何东西,甚至没有触发PostBack。

usercontrol上的AutoEventWireUp设置为true。 Repeater ItemDataBound在Markup中设置。但即便如此,ImageButton仍然不会触发任何类型的动作。

根本不会发生射击的原因是什么?

以下是HTML标记:

<%@ Control Language="vb" AutoEventWireup="true" Codebehind="BiddersGroupList.ascx.vb"
    Inherits="FXWB.BidPackage.BiddersGroupList" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<%@ Register TagPrefix="fxwb" TagName="GridLabel" Src="~/Secure/Controls/GridLabel.ascx" %>

<telerik:RadCodeBlock ID="rcbScripts" runat="server">
<script>
      function pb(ctrl,FolderId, B, BID, CID)
      {
//        debugger;
        var lblid = ctrl.parentElement.parentElement.cells[7].childNodes[0].id;
        SethdnUpdatedValues(lblid, (B=='WB') ? 'Yes' : 'No');
      NoRefreshRequestProcessor_SendRequest('changeBidStatus:'+B+':'+BID+':'+CID);
      }

      function ir(ctrl,FolderId, BID, CID)
      {
        debugger;
        if(ctrl.checked ==true)
            B = '1';
        else
            B = '0';        
        NoRefreshRequestProcessor_SendRequest('changeAdminIsRceived:'+B+':'+BID+':'+CID);
      }

      function pw(BPID, SUID, FID){
      var BID ='Owner';
      window.open('Bidpackage/ReplyToBid.aspx?BPID='+ BPID + '&SUID='+SUID+'&BID='+BID + '&FID='+ FID + '&a=edit','_blank','height=600,width=800,status=yes,toolbar=no,menubar=no,location=no, scrollbars=yes, resizable = yes');
      }


      function be(BID, BPID,CSI){
      window.open('Bidpackage/EditBidderInfo.aspx?BidderID='+BID+'&BidPackageID='+BPID+'&CSI='+CSI,'bidder_edit','height=550,width=950,status=yes,toolbar=no,menubar=no,location=no, scrollbars=yes, resizable = yes')
      }

      function one(sender,NID,CsiValue,lblid){
      //debugger;
        NoteLabelID=lblid;
      var url = 'Bidpackage/BidderNoteEdit.aspx?NoteID='+escape(NID)+'&CSI='+CsiValue;
      var Top = (screen.availHeight / 2) - 100; //getY(sender) - document.getElementById('FolderBody').scrollTop + 226;
      var Left = (screen.availWidth / 2) - 150; //getX(sender) + 280;
      var params = 'height=200, width=300, location=0, top='+Top+', left='+Left+', status=0, scrollbars=0, toolbar=0';
      var arr=NID.split(':');
      window.open(url,'BDR_NOTE_'+escape(arr[0]),params);
      //window.open(url,'BDR_NOTE_'+escape(NID.replace(':','_')),params);
      //window.open(url,params);
      }



      function SelectAll(chkMain)
      { 
      //debugger;
      var mainchk = chkMain.getAttribute("Division");
        var chk = document.documentElement.getElementsByTagName("input");
        var i;
        for(i=0;i<chk.length; i++)
         {
            if(chk[i].type=='checkbox')
            {
             csiChild = chk[i].getAttribute("Division");
              if (csiChild != null)
              {
               if(csiChild == mainchk)
                        {
                            if(chkMain.checked == true)
                               {
                                    chk[i].checked = true;
                                    SelectCodes(chk[i])
                               }
                                else
                                {
                                    chk[i].checked = false;
                                    SelectCodes(chk[i])
                                }
                        }
              }

            }
            }

      }
       function SelectCodes(chkMain)
      { 
     // debugger;
      var mainchk = chkMain.getAttribute("CSI");
        var chk = document.documentElement.getElementsByTagName("input");
        var i;
        for(i=0;i<chk.length; i++)
         {
            if(chk[i].type=='checkbox')
            {
             csiChild = chk[i].getAttribute("CSI");
              if (csiChild != null)
              {
               if(csiChild == mainchk)
                        {
                            if(chkMain.checked == true)
                               {
                                    chk[i].checked = true;
                               }
                                else
                                {
                                    chk[i].checked = false;
                                }
                        }
              }

            }
            }

      }


function CheckAllBidders(chkMain)
      {
     // debugger;
        var mainCSI = chkMain.getAttribute("CSI");
        var csi;
        var csiChild;
        var bidder;
        var chkChildID;

        var chk = document.documentElement.getElementsByTagName("input");
        var i;
        for(i=0;i<chk.length; i++)
         {
            if(chk[i].type=='checkbox')
            {

//                chkChildID = chk[i].id;
//                s = chkChildID.indexOf(":");
                    csiChild = chk[i].getAttribute("CSI");
                      bidder = chk[i].getAttribute("Bidder");
                    if (csiChild != null && bidder != null)
                    {

                        if(csiChild==mainCSI)
                        {
                       // debugger;
                               if(chkMain.checked == true)
                               {
                                    chk[i].checked = true;
                               }
                                else
                                {
                                    chk[i].checked = false;
                                }
                         }
                    }
            }

         }

      }

var btnReloadExpandedID = '<%=ButtonReloadExpanded.ClientID %>';
var hdnExpandBidderID = '<%=hdnExpandBidder.ClientID %>';

var btnBindBiddingStatus = '<%=ButtonBindBiddingStatus.ClientID %>';
var btnBindNotes = '<%=ButtonBindNotes.ClientID %>';
var hdnNoteCSI = '<%=hdnNoteCSI.ClientID %>';
var hdnCSIId1 = '<%=hdnCSIId1.ClientID %>';
var hdnExpandCSIs = '<%=hdnCSIIs.ClientID %>';
var NoteLabelID;
</script>

<script>
function BindNote(csivalue1,note)
{
//    var ButtonBindNotes1 = document.getElementById(btnBindNotes);
//    var HiddenNotesCSI1 = document.getElementById(hdnNoteCSI);
//    HiddenNotesCSI1.value = csivalue1;
//    ButtonBindNotes1.click();

    document.getElementById(NoteLabelID).innerHTML = note;
    SethdnUpdatedValues(NoteLabelID,note);
}

function SethdnUpdatedValues(id,value)
{
//debugger;
    if (id!=undefined)
    {
        var hdnUpdatedValues = document.getElementById('<%=hdnUpdatedValues.ClientID %>');
        if(hdnUpdatedValues.value!="")
            if(hdnUpdatedValues.value.indexOf(id) !=-1)
            {
                var st = hdnUpdatedValues.value.indexOf(id);
                var end = hdnUpdatedValues.value.indexOf("|~|",st);
                var valToReplace = hdnUpdatedValues.value.substring(st,end);
                var valReplaceBy = id + "=" + value;
                hdnUpdatedValues.value = hdnUpdatedValues.value.replace(valToReplace, valReplaceBy);
            }
            else
                hdnUpdatedValues.value = hdnUpdatedValues.value + id + '=' + value + '|~|';
         else
            hdnUpdatedValues.value = id + '=' + value + '|~|';
   }
}

function SetUpdatedValues()
{
//debugger;
    try
    {
        var hdnUpdatedValues = document.getElementById('<%=hdnUpdatedValues.ClientID %>');

        if (hdnUpdatedValues.value != "")
        {
            var values = hdnUpdatedValues.value.split('|~|');
            var ctrlValue;
            var i;
            for(i=0; i<values.length-1;i++)
            {
                ctrlValue = values[i].split('=');
                document.getElementById(ctrlValue[0]).innerHTML = ctrlValue[1];
            }
        }
    }
    catch(ex)
    {
    }
}






</script>
</telerik:RadCodeBlock>

<asp:UpdateProgress ID="UpdateProgress1" runat="server" DynamicLayout="true">
    <ProgressTemplate>
        <div style="background-color: White; position: absolute; z-index: 10; left: expression((this.offsetParent.clientWidth/2)-(this.clientWidth/2)+this.offsetParent.scrollLeft);
            top: expression((this.offsetParent.clientHeight/2)-(this.clientHeight/2)+this.offsetParent.scrollTop);">
            <img src="../Images/LoadingIcon.gif" height="80" width="150" />
        </div>
    </ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="UpdatePannel1" runat="server">
    <ContentTemplate>
        <%--<script type="text/javascript" language=javascript>
    function ShowData()
{
        var trValues = document.getElementById('<%=trRptrDivision.ClientID %>');
        trValues.style.visibility="visible";
}
    </script>--%>
        <asp:HiddenField ID="hdnUpdatedValues" runat="server" />

        <script language="javascript">
            Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
            function EndRequestHandler(sender, args)
            {

                SetUpdatedValues();
            } 
        </script>

        <asp:Label ID="lblTestStatus" runat="server"></asp:Label>
        <input type="button" id="ButtonReloadExpanded" runat="server" style="display: none;"
            value="Reload Expanded" />
        <input type="button" id="ButtonBindBiddingStatus" runat="server" style="display: none;"
            value="Bind BiddingStatus" />
        <input type="button" id="ButtonBindNotes" runat="server" style="display: none;" value="Bind Notes" />
        <asp:HiddenField ID="hdnExpandBidder" runat="server" />
        <asp:HiddenField ID="hdnNoteCSI" runat="server" />
        <asp:HiddenField ID="hdnCSIId1" runat="server" />
        <asp:HiddenField ID="hdnCSIIs" runat="server" />
        <table border="1" cellpadding="0" cellspacing="0" style="background: skyblue; border-style: solid;
            border-width: 1px; border-color: black;" width="100%" id="tblBiddersList">
            <tr>
                <td colspan="3">
                    <asp:Label ID="lblError" runat="server" Font-Size="8pt" ForeColor="Red" Font-Bold="True"
                        EnableViewState="False" Font-Names="Arial"></asp:Label>
                </td>
            </tr>
            <asp:Repeater ID="rptdivision" runat="server" EnableViewState="true" OnItemDataBound="rptdivision_ItemDataBound">
                <HeaderTemplate>
                    <tr>
                        <td class="MasterHeader">
                            <asp:Button ID="ButtonExpandCollapse" UseSubmitBehavior="false" runat="server" Text="Expand All" CssClass="button"
                                CommandName="ExpandCollapse" />
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Divisions
                        </td>
                        <td class="MasterHeader">
                            Divisions Description
                        </td>
                    </tr>
                </HeaderTemplate>
                <ItemTemplate>
                    <tr style="background-color: #66cc99;">
                        <td>
                            <input type="checkbox" id="chkDivision" biddercount='<%#DataBinder.Eval(Container, "DataItem.countBidders")%>'
                                runat="server" onclick="javascript:SelectAll(this);" />
                            <%--  <asp:CheckBox ID="chkDivision" runat="server" onclick="javascript:SelectAll(this);" />--%>
                            <asp:ImageButton runat="server" ID="ImageButton1" CommandName="ExpandDivision" ImageUrl="~/Secure/Images/plus_big.gif" />
                            <asp:Label ID="lbDivisionName" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.classifier_name")%>'></asp:Label>
                            <%--                            <asp:HiddenField ID="hfcgroup" runat="server" Value='<%#DataBinder.Eval(Container, "DataItem.csigroup")%>' />--%>
                        </td>
                        <td>
                            <asp:Label ID="Label1" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.classifier_description")%>'></asp:Label>
                        </td>
                    </tr>
                    <tr class="trup" id="trRptrDivision" runat="server" style="background: white;">
                        <td>
                            <asp:Repeater ID="rptrBidPackage" runat="server" OnItemCommand="rptrBidPackage_ItemCommand">
                                <%--<HeaderTemplate>
                    <tr>
                        <td class="MasterHeader">
                            <asp:Button ID="ButtonExpandCollapse" runat="server" Text="Expand All" CssClass="button"
                                CommandName="ExpandCollapse" />
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; CSI Code
                        </td>
                        <td class="MasterHeader">
                            CSI Description
                        </td>
                    </tr>
                </HeaderTemplate>--%>
                                <ItemTemplate>
                                    <tr class="trup" style="margin: 0px 0px 0px 0px; height: 0%; display: none" id="trMaster"
                                        runat="server">
                                        <td class="tdupMaster">
                                            <asp:ImageButton runat="server" ID="ImageColapseExpand" CommandName="Expand" CommandArgument='<%#DataBinder.Eval(Container, "DataItem.CSIValue")%>'
                                                ImageUrl="~/Secure/Images/plus_big.gif" />
                                            <b>
                                                <input type="checkbox" id="chkCodes" biddercount='<%#DataBinder.Eval(Container, "DataItem.countBidders")%>'
                                                    runat="server" onclick="javascript:SelectCodes(this);" />
                                                <%--   <asp:CheckBox ID="chkCodes" runat="server" onclick="javascript:CheckCodes();" />&nbsp;--%>
                                                <asp:Label ID="LabelCSI" runat="server" Text='<%#DataBinder.Eval(Container, "DataItem.CSIValue")%>'></asp:Label>
                                            </b>
                                        </td>
                                        <td class="tdupMaster">
                                            <em>
                                                <%#DataBinder.Eval(Container, "DataItem.CSIDesc")%>
                                            </em>
                                        </td>
                                    </tr>
                                    <tr class="trup" id="trRptrBidders" runat="server" style="background: white; display: none">
                                        <td colspan="2">
                                            <table border="1" width="100%" cellpadding="1" cellspacing="1" style="background: #eeeeee;">
                                                <asp:Repeater ID="rptrBidders" runat="server" EnableViewState="true" OnItemDataBound="rptrBidders_ItemCreated">
                                                    <HeaderTemplate>
                                                        <tr style="background: #cccccc; color: #205f7d; font-weight: bold; font-size: x-small;"
                                                            class="DetailHeader">
                                                            <td class="DetailHeader" align="right">
                                                                <input type="checkbox" id="chkSelectAll" runat="server" onclick="javascript:CheckAllBidders(this);" />
                                                            </td>
                                                            <td class="DetailHeader">
                                                                Action
                                                            </td>
                                                            <td class="DetailHeader">
                                                                Company name
                                                            </td>
                                                            <td class="DetailHeader">
                                                                Contact
                                                            </td>
                                                            <td class="DetailHeader">
                                                                Phone
                                                            </td>
                                                            <td class="DetailHeader">
                                                                Fax
                                                            </td>
                                                            <td class="DetailHeader">
                                                                Email</td>
                                                            <td class="DetailHeader">
                                                                Will Bid</td>
                                                        </tr>
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <tr class="trup" runat="server" id="trBidder">
                                                            <td rowspan="2" style="width: 50px;" id="tdCheckBox" align="right">
                                                                <asp:Label runat="server" ID="lblIsReceived" Text="+" Font-Bold="true" Visible="false"></asp:Label>
                                                                <input type="checkbox" id="chkBidder" runat="server" />
                                                                <input type="hidden" runat="server" id="hdnFaxStatus" value='<%#DataBinder.Eval(Container, "DataItem.FaxStatus")%>' />
                                                                <input type="hidden" runat="server" id="hdnIsReceived" value='<%#DataBinder.Eval(Container, "DataItem.IsReceived")%>' />
                                                            </td>
                                                            <td rowspan="2" style="width: 0%;">
                                                                <img style="margin: 0px;" onclick="pw('<%#DataBinder.Eval(Container, "DataItem.BidpackageID")%>','<%#DataBinder.Eval(Container, "DataItem.SiteUserID")%>','<%#DataBinder.Eval(Container, "DataItem.FolderID")%>');"
                                                                    src="Images/tool_preview.gif" alt="View"></img><img style="margin: 0px;" src="Images/BidPackage/tool_bidder_edit.gif"
                                                                        alt="Edit Bidder Info" onclick="be('<%#DataBinder.Eval(Container, "DataItem.BidderID")%>','<%#DataBinder.Eval(Container, "DataItem.BidpackageID")%>','<%#DataBinder.Eval(Container, "DataItem.CSIs!2!CSI")%>')"></img><img
                                                                            style="margin: 0px;" src="Images/BidPackage/tool_approve_f2.gif" alt="Will Bid"
                                                                            onclick="pb(this,'<%#DataBinder.Eval(Container, "DataItem.FolderID")%>','WB','<%#DataBinder.Eval(Container, "DataItem.BidderID")%>','<%#DataBinder.Eval(Container, "DataItem.CsiID")%>');"></img><img
                                                                                style="margin: 0px;" src="Images/BidPackage/tool_decline_f2.gif" alt="Will Not Bid"
                                                                                onclick="pb(this,'<%#DataBinder.Eval(Container, "DataItem.FolderID")%>','NB','<%#DataBinder.Eval(Container, "DataItem.BidderID")%>','<%#DataBinder.Eval(Container, "DataItem.CsiID")%>');"></img><asp:CheckBox
                                                                                    ID="chkIsReceived" ToolTip="Admin IsReceived" runat="server" FolderID='<%#DataBinder.Eval(Container, "DataItem.FolderID")%>'
                                                                                    Checked='<%#DataBinder.Eval(Container, "DataItem.AdminIsReceived")%>' />
                                                            </td>
                                                            <td class="fn">
                                                                <input type="hidden" runat="server" id="hdnBidder" value='<%#DataBinder.Eval(Container, "DataItem.BidderID")%>' />
                                                                <input type="hidden" runat="server" id="hdnCsiID" value='<%#DataBinder.Eval(Container, "DataItem.CsiID")%>' />
                                                                <%#DataBinder.Eval(Container, "DataItem.Organization")%>
                                                            </td>
                                                            <td class="fn">
                                                                <%#DataBinder.Eval(Container, "DataItem.FullName")%>
                                                            </td>
                                                            <td class="fn">
                                                                <nobr>
                                                <%#DataBinder.Eval(Container, "DataItem.Phone")%>
                                                </nobr>
                                                            </td>
                                                            <td class="fn">
                                                                <nobr>
                                                <%#DataBinder.Eval(Container, "DataItem.Fax")%>
                                                </nobr>
                                                            </td>
                                                            <td class="fn">
                                                                <nobr>
                                                <%#DataBinder.Eval(Container, "DataItem.EMail")%>
                                                </nobr>
                                                            </td>
                                                            <td class="fn">
                                                                <asp:Label ID="lblWillBid" runat="server">
                                                <%#DataBinder.Eval(Container, "DataItem.WillBid")%>
                                                                </asp:Label>
                                                            </td>
                                                        </tr>
                                                        <tr id="trBidderNote">
                                                            <td colspan="6" style="font-size: xx-small; background-color: #FEFEFE; padding: 0px;">
                                                                <span id="spanBidderNote" runat="server" class="Note">Note:</span>&#160;
                                                                <input type="hidden" runat="server" id="hdnBidderNoteID" value='<%#DataBinder.Eval(Container, "DataItem.BidderNoteID")%>' />
                                                                <div style="height: 100%; width: 210px; border: solid 0px gray; display: inline;"
                                                                    id="note">
                                                                    <asp:Label ID="lblBidderNote" runat="server">
                                                    <%#DataBinder.Eval(Container, "DataItem.BidderNote")%>
                                                                    </asp:Label>
                                                                </div>
                                                                &#160;&#160;&#160;
                                                                <%#DataBinder.Eval(Container, "DataItem.Qualifications")%>
                                                            </td>
                                                        </tr>
                                                    </ItemTemplate>
                                                </asp:Repeater>
                                                <%--                                <asp:GridView ID="GridViewBidders" runat="server" EnableViewState="true" Visible="false">
                                </asp:GridView>--%>
                                            </table>
                                        </td>
                                    </tr>
                                </ItemTemplate>
                            </asp:Repeater>
                        </td>
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
        </table>
    </ContentTemplate>
</asp:UpdatePanel>

1 个答案:

答案 0 :(得分:0)

您的转发器位于更新面板内,因此请使用异步类型的触发器,如下所示:

<Triggers>
        <asp:AsyncPostBackTrigger ControlID="imagebtn" EventName="CLICK" />
    </Triggers>

并对转发器的代码进行一些更改......

<asp:ImageButton runat="server" ID="ImageColapseExpand" onclick="ImageColapseExpand_Click" CommandArgument='<%#DataBinder.Eval(Container, "DataItem.CSIValue")%>'
                                            ImageUrl="~/Secure/Images/plus_big.gif" />
                                        <b>

在后面的代码中创建一个click事件,如下所示:

protected void ImageColapseExpand_Click(object sender, ImageClickEventArgs e)
{

}

希望这对你有用......