嵌套更新面板中的linkbutton错误

时间:2012-02-05 00:46:18

标签: c# asp.net updatepanel

我有一个页面显示有评论和子评论的帖子,每个评论都有一个回复链接按钮,当点击它显示一个文本框和一个按钮添加子评论,问题是链接按钮只能工作第一次和第二次....第三次没什么好开心我尝试调试它,我什么都没有,它没有去服务器这里是代码

<asp:UpdatePanel ID="UpdatePanel1" runat="server"  UpdateMode="Conditional" ChildrenAsTriggers="false">
            <Triggers> 
                  <asp:AsyncPostBackTrigger ControlID="addComment_btn" /> 
            </Triggers> 
            <ContentTemplate>

                <asp:Repeater ID="Repeater1" runat="server" 
                    onitemdatabound="Repeater1_ItemDataBound" 
                onitemcommand="Repeater1_ItemCommand">
                <ItemTemplate>
                <ol class="cosmo-comment-list cosmo-comment-plain">
            <li class="comment even thread-even depth-1" id="li-comment-2">
                  <div id="comment-2" class="comment-body">
                  <asp:HiddenField ID="commentID_hidden" runat="server" 
                                            Value='<%# Eval("comments_ID") %>' />
                <div class="cosmo-comment-thumb"><img alt="" src="images/default_avatar.jpg" class="avatar avatar-60 photo" height="60" width="60"></div>
                <div class="cosmo-comment-leftpointer"></div>
                <div class="cosmo-comment-quote">
                    <div class="cosmo-comment-textinfo">
                    <span class="user"><a href="#" rel="external nofollow" class="url"><%# Eval("commenter_name")%></a></span>
                    <span class="time"><%#Eval("comment_date")%> </span>
                    <span class="gray reply fr"><a class="comment-reply-link" href="#">

                     <asp:UpdatePanel ID="UpdatePanel2" runat="server"  UpdateMode="Conditional">
                    <ContentTemplate>

                        <asp:LinkButton ID="reply_linkbtn" runat="server" Visible="false" CommandName="reply">Reply</asp:LinkButton>

                        </ContentTemplate>
                        <Triggers> 
                       <asp:AsyncPostBackTrigger ControlID="reply_linkbtn" /> 
                   </Triggers> 
                    </asp:UpdatePanel>

                    </a></span>
                    </div>
                        <p> <%# Eval("text") %> </p>
                </div>
                </div>

                                           </li>
                        </ol>

                    <asp:UpdatePanel ID="UpdatePanel1" runat="server"  UpdateMode="Conditional">
                    <Triggers> 
                       <asp:AsyncPostBackTrigger ControlID="reply_linkbtn" /> 
                   </Triggers> 
                    <ContentTemplate>
                     <asp:TextBox ID="subcomment_textbox" runat="server" Visible="false"></asp:TextBox>
                    <asp:Button ID="add_subcomment_btn"
                        runat="server" Text="Button" Visible="false"/>

                    </ContentTemplate>
                    </asp:UpdatePanel>
                 </ItemTemplate>
                </asp:Repeater>
              </ContentTemplate>
            </asp:UpdatePanel>

编辑:问题修复了它在后面的代码中我不知道实际的原因但是在页面加载中我总是调用repeater.Databind()方法而导致问题..当我做了条件if(!IsPostBack)然后绑定数据时问题得到了修复

0 个答案:

没有答案