尽管使用了更新面板,整个网页仍然刷新 [英] Entire webpage still refreshes despite using update panel

查看:92
本文介绍了尽管使用了更新面板,整个网页仍然刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,现在的问题是,尽管我使用的是更新面板,但是只要我在更新面板中进行任何更新,整个网页都会刷新.

Ok right now the problem i have is that although i am using update panel, whenever i am updating anything within the update panel, the entire webpage would refresh.

这是代码

 <div id="firstbar">
          <asp:UpdatePanel ID="UpdatePanel1" runat="server"  >
                <ContentTemplate>    
        <div style="width:15%;float:left;">

            <asp:Image ID="Image1" runat="server" ImageUrl="~/Img/Untitled1.png" CssClass="imagez" />

        </div>
         </ContentTemplate>

        <div style="width:85%;float:left;height:100%;padding-top:2%;">

            <asp:Label ID="Label2" runat="server" Text="CPU" CssClass="auto-style7" Font-Names="sans-serif"></asp:Label>
            <br />

            <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" CssClass="bla" DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="Name" Font-Names="sans-serif" AppendDataBoundItems="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" >
    <asp:ListItem Selected="True">Pick a CPU</asp:ListItem>
    </asp:DropDownList>
            <asp:UpdatePanel ID="UpdatePanel17" runat="server">
            <ContentTemplate>

            <strong>

            <asp:Label ID="Label3" runat="server" Text="$" CssClass="auto-style8" Font-Names="sans-serif"></asp:Label>
                <asp:Label ID="Label4" runat="server" Text="0.00" CssClass="auto-style8" Font-Names="sans-serif"></asp:Label>
            </strong>

        </div>
            </ContentTemplate>
               </asp:UpdatePanel>

    </div>

推荐答案

更新"面板仅包含非交互控件(标签和图像),而交互项(例如自动回发下拉列表)不在更新面板之外.只有在更新面板内部中启动的回发才会导致部分回发.因此,您必须将这些控件移到更新面板中.例如,下拉列表:

Your Update panel contains only non-interactive controls (labels and images), while the interactive items (like the auto-postback dropdown list) are outside the update panel. Only postbacks that are initiated inside the the update panel will cause a partial postback. So you have to move those controls into the update panel. For example the drop down list:

<div style="width:85%;float:left;height:100%;padding-top:2%;">

            <asp:Label ID="Label2" runat="server" Text="CPU" CssClass="auto-style7" Font-Names="sans-serif"></asp:Label>
            <br />

            <asp:UpdatePanel ID="UpdatePanel17" runat="server">
            <ContentTemplate>
            <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" CssClass="bla" DataSourceID="SqlDataSource1" DataTextField="Name" DataValueField="Name" Font-Names="sans-serif" AppendDataBoundItems="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" >
    <asp:ListItem Selected="True">Pick a CPU</asp:ListItem>
    </asp:DropDownList>

            <strong>

            <asp:Label ID="Label3" runat="server" Text="$" CssClass="auto-style8" Font-Names="sans-serif"></asp:Label>
                <asp:Label ID="Label4" runat="server" Text="0.00" CssClass="auto-style8" Font-Names="sans-serif"></asp:Label>
            </strong>

        </div>
            </ContentTemplate>
               </asp:UpdatePanel>
</div>

这篇关于尽管使用了更新面板,整个网页仍然刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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