2017-08-10 40 views
0

我有兩個鏈接按鈕在我的Index.aspx禁用ViewState中的ASP:LinkBut​​ton的

<form id="MyForm" runat="server"> 
          <asp:ScriptManager ID="ScriptManager1" runat="server"> 
          </asp:ScriptManager> 
          <asp:UpdatePanel ID="subscriptionPanel" runat="server" ValidationGroup="SubscriptionGroup"> 
           <ContentTemplate> 
            <div class="input-prepend"> 
             <span class="add-on"><i class="icon-envelope"></i></span> 
             <asp:TextBox ID="txtEmail" runat="server" CssClass="form-control" autocomplete="off" placeholder="[email protected]" ValidationGroup="SubscriptionGroup"></asp:TextBox><br /> 

            </div> 
            <br /> 
            <asp:Button ID="btnSubscribe" runat="server" Text="Subscribe Now!" CssClass="btn btn-large" OnClick="btnSubscribe_Click" ValidationGroup="SubscriptionGroup" /> 
            <li style="visibility: hidden;"> 
             <asp:LinkButton ID="LinkButton1" runat="server" EnableViewState="false" OnClick="btnHindiCulture" ValidationGroup="HindiLanguage" CausesValidation="false">Hindi</asp:LinkButton></li> 
            <%--<asp:Button ID="btnHidden" runat="server" Text="Hidden" OnClick="btnHidden_Click" />--%> 
           </ContentTemplate> 
          </asp:UpdatePanel> 
</form> 

我想禁用視圖狀態的LinkBut​​ton1爲此我使用的EnableViewState =「假」。我仍然在Request.Form中獲得ViewState數據。

ViewStateData是如下圖所示的圖像:

enter image description here

如何禁用此視圖狀態數據?

+2

禁用ViewState中的一個控件並不意味着它會消失。其他控件也在使用它。即使您在頁面級別設置了EnableViewState =「false」,輸入仍然會在那裏。 – VDWWD

回答

0

在.NET Framework 4中頁面指令把下面的標籤:

ViewStateMode="Disabled" 

,並使用這個是要保存ViewState中每個控件(如):

<asp:DropDownList ID="ddl" runat="server" ViewStateMode="Enabled"> 
</asp:DropDownList> 
相關問題