UpdatePanel AsyncPostBackTrigger执行回发

时间:2016-02-16 10:14:31

标签: c# asp.net visual-studio gridview updatepanel

我在design code下面updatepanel gridviewbuttons下方,如下所示 -

<asp:ScriptManager ID="scrptmanager" runat="server"></asp:ScriptManager>
    <div>
        <asp:HiddenField ID="hdnSortValue" runat="server" />
    </div>
    <div class="current-btns" style="float: left !important;">
        <div id="divFitnessSortBy" runat="server" class="fit-sort">
            <table>
                <tr>
                    <td>
                        <b>Sort by :</b>
                    </td>
                    <td>
                        <asp:Button ID="btnMostRecent" Text="Most Recent" class="button action sortcomments"
                            runat="server" OnCommand="btnMostRecent_Click" CommandArgument="date" />
                    </td>
                    <td>
                        <asp:Button ID="btnMostViewed" Text="Most Viewed" class="Comments" runat="server"
                            OnCommand="btnMostViewed_Click" CommandArgument="views" />
                    </td>
                </tr>
            </table>
        </div>
        <div class="clear">
        </div>
    </div>
    <div class="hr">
    </div>
    <div class="BlogsPostHolderDiv" id="divPagination">
    <asp:UpdatePanel ID="updtpanel" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:GridView ID="gvBlogsPost" runat="server" DataKeyNames="PostID" AutoGenerateColumns="False"
            AllowPaging="false" Width="100%" OnRowDataBound="gvBlogsPost_Bound" GridLines="None">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <div class="current-articles">
                            <div class="current-thumb">
                                <a id="lnkThumbnail" runat="server" rel="nofollow">
                                    <asp:Image ID="imgThumbnail" runat="server" Height="135px" Width="186px" />
                                </a>
                            </div>
                            <div class="current-list">
                                <h2>
                                    <a id="lnkArticle" runat="server">
                                        <%# DataBinder.Eval(Container.DataItem, "Subject")%></a>
                                </h2>
                                <div class="views-comments">
                                    <h5>
                                        <asp:Label runat="server" ID="lblNewsletterDate" ForeColor="#808080"><%# DataBinder.Eval(Container.DataItem, "PostDate")%></asp:Label>
                                        <span class="gray">|</span> <span id="spnViews" runat="server"><span>
                                            <%#Convert.ToInt64(DataBinder.Eval(Container.DataItem, "TotalViews")).ToString("#,#")%>
                                            Views </span></span>
                                    </h5>
                                </div>
                                <asp:Label ID="lblShortDescription" runat="server"><%#DataBinder.Eval (Container.DataItem, "Body")%> </asp:Label>
                            </div>
                            <div class="clear">
                            </div>
                        </div>
                        <div class="hr">
                        </div>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>

        </asp:GridView>
        </ContentTemplate>
        <Triggers>
        <asp:AsyncPostBackTrigger ControlID="btnMostRecent" EventName="Click" />
        <asp:AsyncPostBackTrigger ControlID="btnMostViewed" EventName="Click" />
        </Triggers>
        </asp:UpdatePanel>            
    <input type="hidden" id="hdnLastArticle" value="10" />

click btnMostRecentbtnMostViewed页面postback click不应该是这样的情况时......我在这里遗漏了什么?

预期 - 如果button任何一个gvBlogsPost gridview whole page postback {}仅String htmlStringGot = parsedJSONStringValue; txt.setText(Html.fromHtml(Html.fromHtml(htmlStringGot).toString())); 更新.modal-dialog

提前帮助和谢谢......!

1 个答案:

答案 0 :(得分:0)

看起来你唯一需要做的就是确保触发器位于同一个命名容器中。

根据MSDN

  

AsyncPostBackTrigger控件引用的控件必须是   在与其所属的更新面板相同的命名容器中   触发。基于其他命名中的控件的触发器   不支持容器。