为asp:Linkbutton禁用ViewState

时间:2017-08-10 07:09:28

标签: asp.net webforms viewstate

我的index.aspx

中有两个链接按钮
<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="your@email.com" 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>

我想为我正在使用EnableViewState =“false”的LinkBut​​ton1禁用Viewstate。我仍然在Request.Form中获取ViewState数据。

ViewStateData如下图所示:

enter image description here

如何为此禁用viewstate数据?

1 个答案:

答案 0 :(得分:0)

在.NET框架中4.在页面指令中添加以下标记:

undefined

并将其用于要保存Viewstate的每个控件(例如):

 ViewStateMode="Disabled"