好了,我现在遇到的问题是,虽然我正在使用更新面板,但每当我在更新面板中更新任何内容时,整个网页都会刷新。
这是代码
<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>
答案 0 :(得分:0)
“更新”面板仅包含非交互式控件(标签和图像),而交互式项目(如自动回发下拉列表)位于更新面板之外。只有在内部更新面板中启动的回发才会导致部分回发。因此,您必须将这些控件移动到更新面板中。例如下拉列表:
<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>