2012-09-13 125 views
0

我必須動態地填充Sharepoint站點中更新面板內的複選框。 問題是,儘管我單擊按鈕後清除了選擇,但該複選框以某種方式記住了以前的選擇,並顯示了checkbox.items [i]。即使對於之前的選擇也選擇爲true 如果刪除更新panel.However我不能刪除更新面板怎麼把整個頁面重新加載每次做出選擇 時間下面是我的代碼 動態填充複選框會記住以前的選擇

   <div align="left"> 
       <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="True" > 
       <ContentTemplate> 
       <asp:CheckBoxList BackColor="White" AutoPostBack="true" ID="cbHideTabs" 
         runat="server" isCheckable="true" ForeColor="#0072bc" Width="300px" > 
         </asp:CheckBoxList> 

        <input type ="button" Visible ="true" ID="HideShowTabButton" value="HideShowTab" title="HideShowTab" runat="server" style="background-color: #0072bc; color: #FFFFFF;" enableviewstate="False" /> 

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

     <br /> 

     <asp:PopupControlExtender ID="PopupControlExtender1" Enableviewstate="false" runat="server" CommitProperty="value" 
      PopupControlID="Panel1" 
      Position="Bottom" TargetControlID="ShowHideLabel"> 
     </asp:PopupControlExtender> 

回答

0

你能分享你正在使用清除選擇的代碼。

我修改了你的代碼,併爲我工作。

的aspx頁面代碼

<%@ Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false" 
    CodeBehind="Default.aspx.vb" Inherits="UpdateCheckbox._Default" %> 

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent"> 
</asp:Content> 
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> 
    <div> 
    <asp:scriptmanager ID="Scriptmanager1" runat="server"></asp:scriptmanager> 
    <asp:updatepanel ID="Updatepanel1" runat="server"> 
    <ContentTemplate> 
       <asp:CheckBoxList ID="chkAll" BackColor="White" AutoPostBack="true" 
         runat="server" isCheckable="true" ForeColor="#0072bc" Width="300px" > 
         <asp:ListItem Enabled="true" Text="1"></asp:ListItem> 
         <asp:ListItem Enabled="true" Text="1"></asp:ListItem> 
         <asp:ListItem Enabled="true" Text="1"></asp:ListItem> 
<asp:ListItem Enabled="true" Text="1"></asp:ListItem> 
<asp:ListItem Enabled="true" Text="1"></asp:ListItem> 
<asp:ListItem Enabled="true" Text="1"></asp:ListItem> 
<asp:ListItem Enabled="true" Text="1"></asp:ListItem> 
         <asp:ListItem Enabled="true" Text="1"></asp:ListItem> 
         </asp:CheckBoxList> 
<asp:Button runat="server" Text="HideShowTab" runat="server" OnClick="Clear_Click" style="background-color: #0072bc; color: #FFFFFF;" enableviewstate="False" /> 

      </ContentTemplate> 

    </asp:updatepanel> 
</div> 
</asp:Content> 

代碼在vb.net

Protected Sub Clear_Click(ByVal sender As Object, ByVal e As System.EventArgs) 
     chkAll.ClearSelection() 
    End Sub 
+0

Pushpendra嗨,我使用下面的代碼來清除我的文本框,並關閉popupextender'cbHideTabs.ClearSelection(); PopupControlExtender1.Cancel();'我也不能添加像你這樣的腳本管理器,因爲它已經被添加到同一頁面上使用的另一個用戶控件中,我想我們每頁只能使用一個腳本管理器。 – NandiniHegde

+0

是的,非常真實腳本管理器在頁面上只能有一個實例,否則您會收到錯誤: 只有一個ScriptManager實例可以添加到頁面中。 但是,更好的選擇我會建議您將腳本管理器移動到母版頁。 – Pushpendra

+0

但問題仍然存在。你認爲這是因爲只有腳本管理器。也因爲這是一個SharePoint站點頁面我不明白你的意思是一個母版頁。 – NandiniHegde