2016-11-25 82 views
0

好吧現在我的問題是,雖然我使用更新面板,每當我更新更新面板內的任何內容,整個網頁將刷新。整個網頁仍然刷新,儘管使用更新面板

下面是代碼

<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

的可能的複製[?什麼是一個NullReferenceException,以及如何解決呢(http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception - 我怎麼辦 - 我 - 修復它) – VDWWD

+0

http://stackoverflow.com/questions/5178203/sys-webforms-pagerequestmanagerservererrorexception-status-code-500 – jignesh

+0

嘿jignesh,我跟着那個鏈接,我有一個加法錯誤未捕獲ReferenceError:Sys未定義 – Nicholas

回答

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> 
+0

通過這樣做,我將得到此錯誤未捕獲錯誤:Sys.WebForms.PageRequestManagerServerErrorException:對象引用未設置爲一個東西。 – Nicholas

+0

檢查異常的堆棧跟蹤,這是非.NET消息中的'NullReferenceException'的文本。檢查任何內部異常的堆棧跟蹤。您所描述的問題很可能與更新面板無關。你可能必須通過你的事件處理程序。 – Sefe

+0

這是我不斷收到的錯誤:在Function.Error $ create [as create](http:// localhost:58930/ScriptResource.axd? – Nicholas