[CLOSED] Disabling ViewState

  1. #1

    [CLOSED] Disabling ViewState

    Hi,

    Just some question on disabling viewstate.

    1. What's the difference between using <page ViewStateMode="Disabled"> on the web.config or disabling it on the ResourceManager?
    2. If it is disabled and I need to use, I just need to set it true in the event (like <Click ViewStateMode="Enabled"), or do I need to enable it again on the <%@ Control or Page?

    Thanks!!
    Last edited by Daniil; Dec 05, 2011 at 5:42 PM. Reason: [CLOSED]
  2. #2
    Quote Originally Posted by SouthDeveloper View Post
    1. What's the difference between using <page ViewStateMode="Disabled"> on the web.config or disabling it on the ResourceManager?
    If you set <page ViewStateMode="Disabled"> in the Web.config, then ViewState will be disabled for all Controls in the Application.

    If you set ViewStateMode="Disabled" at the @Page level, then ViewState will be disabled for all Controls at the Page level.

    If you set ViewStateMode="Disabled" on the Control, then ViewState will be disabled for that Control.

    These are all ASP.NET native properties and not controlled by Ext.NET.

    Setting ViewStateMode="Enabled" on the DirectEvent config will not enable ViewState for that Control.

    If it is disabled and I need to use, I just need to set it true in the event (like <Click ViewStateMode="Enabled"), or do I need to enable it again on the <%@ Control or Page?
    Setting ViewStateMode="Enabled" on the DirectEvent config will only instruct the Ajax Request to send-and-receive ViewState that has already been rendered to the Page. If ViewStateMode="Enabled", the DirectEvent will send/receive the ViewState blob of encrypted data with each transaction.

    If the Controls ViewState has not been rendered because of settings at the Web.config, Page, or Control level, then setting ViewStateMode="Enabled" on the DirectEvent config will not "enable" ViewState for that Application/Page/Controls.

    Hope this helps.
    Geoffrey McGill
    Founder
  3. #3
    Thanks for the quick answer.

    One more thing:

    What´s the difference between <ext:ResourceManager disableViewState='true' /> and <page ViewStateMode="Disabled"> ?
  4. #4
    Please note that native (ASP.NET) viewstate disabling (via Page directive) doesn't remove Control state (ASP.NET doesn't allow to deactivate Control state is required to handle data submiting), VIEWSTATE hidden field will be presented in the page still (with some data)

    If you disable viewstate via resource manager then control state will be removed totaly (and VIEWSTATE hidden field will not presented on the page)
  5. #5
    Quote Originally Posted by SouthDeveloper View Post
    What´s the difference between <ext:ResourceManager disableViewState='true' /> and <page ViewStateMode="Disabled"> ?
    Just to clarify: the answer is:
    Quote Originally Posted by Vladimir View Post
    If you disable viewstate via resource manager then control state will be removed totaly (and VIEWSTATE hidden field will not presented on the page)
    And the information about the ViewStateMode property is in the post #2.
  6. #6

    Failed to disable the viewstate in click direct event

                        <ext:Button ID="btnSave" runat="server" Text="Form.Toolbar.Button.Save" Icon="Disk"
                            OnClientClick="if(storeMain.getTotalCount()>0){formEdit.getForm().updateRecord(storeMain.getAt(0));}else{storeMain.addRecord(formEdit.getForm().getFieldValues(false, 'dataIndex'), false, false);}">
                            <DirectEvents>
                                <Click Url="/Menu/Save" Method="POST" Json="true" Success="hideWindow()" Failure="storeMain.rejectChanges();showErrorMessage(result.message);"
                                    ShowWarningOnFailure="false" CleanRequest="true" ViewStateMode="Disabled" Type="Submit">
                                    <EventMask ShowMask="true" MinDelay="20" Msg="={msgProcessing}" />
                                    <ExtraParams>
                                        <ext:Parameter Name="data" Value="'{'+storeMain.getChangedData()+'}'" Mode="Raw" />
                                    </ExtraParams>
                                </Click>
                            </DirectEvents>
                        </ext:Button>
    I tried disable all viewstate related swithers but still get a very long query string during postback:
    POST /Menu/Save?_dc=1333548574105&ctlMenuName=DefaultAdmin&ctlDescr=Default%20Admin%20Menus&ctlMenuContent=%5B%7Btext%3A%22HoneycombDM%22%2Cchildren%3A%5B%7Btext%3A%22Document%20Management%22%2Cchildren%3A%5B%7Bleaf%3Atrue%2Chref%3A%22%2FDocumentType%2FIndex%22%2ChrefTarget%3A%22_blank%22%2CiconCls%3A%22icon-pagegear%22%2Ctext%3A%22Document%20Type1%22%7D%2C%7Bleaf%3Atrue%2Chref%3A%22%2FDocumentRefnumQual%2FIndex%22%2ChrefTarget%3A%22_blank%22%2CiconCls%3A%22icon-bookopen%22%2Ctext%3A%22Reference%20Qualifier%22%7D%2C%7Bleaf%3Atrue%2Chref%3A%22%2FStatusType%2FIndex%22%2ChrefTarget%3A%22_blank%22%2CiconCls%3A%22icon-lightbulb%22%2Ctext%3A%22Status%20Type1%22%7D%5D%7D%2C%7Btext%3A%22User%20Management%22%2Cchildren%3A%5B%7Bleaf%3Atrue%2Chref%3A%22%2FContact%2FIndex%22%2ChrefTarget%3A%22_blank%22%2CiconCls%3A%22icon-vcard%22%2Ctext%3A%22Contact%22%7D%2C%7Bleaf%3Atrue%2Chref%3A%22%2FUser%2FIndex%22%2ChrefTarget%3A%22_blank%22%2CiconCls%3A%22icon-user%22%2Ctext%3A%22Users%22%7D%2C%7Bleaf%3Atrue%2Chref%3A%22%2FUserRole%2FIndex%22%2ChrefTarget%3A%22_blank%22%2CiconCls%3A%22icon-usersuitblack%22%2Ctext%3A%22User%20Role%22%7D%2C%7Bleaf%3Atrue%2Chref%3A%22%2FUserGroup%2FIndex%22%2ChrefTarget%3A%22_blank%22%2CiconCls%3A%22icon-group%22%2Ctext%3A%22User%20Group%22%7D%2C%7Bleaf%3Atrue%2Chref%3A%22%2FUserGroupProfile%2FIndex%22%2ChrefTarget%3A%22_blank%22%2CiconCls%3A%22icon-grouplink%22%2Ctext%3A%22User%20Group%20Profile%22%7D%5D%7D%2C%7Btext%3A%22Permission%20Management%22%2Cchildren%3A%5B%7Bleaf%3Atrue%2Chref%3A%22%2FPermissionAction%2FIndex%22%2ChrefTarget%3A%22_blank%22%2CiconCls%3A%22icon-vcard%22%2Ctext%3A%22Action%20Permission%22%7D%5D%7D%2C%7Btext%3A%22System%20Setup%22%2Cchildren%3A%5B%7Bleaf%3Atrue%2Chref%3A%22%2FMenu%2FIndex%22%2ChrefTarget%3A%22_blank%22%2CiconCls%3A%22icon-textlistbullets%22%2Ctext%3A%22Menu%22%7D%2C%7Bleaf%3Atrue%2Chref%3A%22%2FExternalSystem%2FIndex%22%2ChrefTarget%3A%22_blank%22%2CiconCls%3A%22icon-serverconnect%22%2Ctext%3A%22External%20System%22%7D%2C%7Bleaf%3Atrue%2Chref%3A%22%2FSetting%2FIndex%22%2ChrefTarget%3A%22_blank%22%2CiconCls%3A%22icon-wrench%22%2Ctext%3A%22Setting%22%7D%2C%7Bleaf%3Atrue%2Chref%3A%22%2FTaskScheduler%2FIndex%22%2ChrefTarget%3A%22_blank%22%2CiconCls%3A%22icon-clock%22%2Ctext%3A%22Task%20Scheduler%22%7D%2C%7Bleaf%3Atrue%2Chref%3A%22%2FTranslation%2FIndex%22%2ChrefTarget%3A%22_blank%22%2CiconCls%3A%22icon-fontgo%22%2Ctext%3A%22Translation%22%7D%5D%7D%5D%7D%5D&__EVENTTARGET=ctl00%24MainContent%24ResourceManager1&__EVENTARGUMENT=btnSave%7Cevent%7CClick HTTP/1.1
    Anyone can help on this? Thanks in advance!
  7. #7
    ViewState is not sent during DirectEvent by default.

    To completely remove ViewState from a page, you can set up
    DisableViewState="true"
    for the ResourceManager.
  8. #8
    Yes, i tried both ResouceManager & Page and even in web.config but all doesn't work...

        <ext:ResourceManager ID="ResourceManager1" runat="server" DebugConsole="None" DisableViewState="true">
            <Listeners>
                <DocumentReady Handler="if(recID.getValue()!=''){storeMain.reload();}" />
            </Listeners>
        </ext:ResourceManager>
    <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" EnableViewState="false" %>
  9. #9
    Quote Originally Posted by Daniil View Post
    ViewState is not sent during DirectEvent by default.
    It's wrong. It's sent on server by default, but doesn't come back from a server by default.

    Anyways, the following
    DisableViewState="true"
    should remove ViewState at all.

    Generally, your query string appears to doesn't consist ViewState, it looks form fields values.

    Please try to set up
    Type="Load"
    for the DirectEvent.
  10. #10
    Type="Load" is working!
    Thanks Daniil!

Similar Threads

  1. [CLOSED] TextField: disabling focus
    By supera in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jun 12, 2012, 4:22 PM
  2. Impact of disabling ViewState
    By mhammami in forum 1.x Help
    Replies: 2
    Last Post: Feb 24, 2012, 5:30 PM
  3. Disabling Panels
    By Dominik in forum 1.x Help
    Replies: 5
    Last Post: May 13, 2011, 1:18 PM
  4. [CLOSED] disabling nodeload
    By ewgoforth in forum 1.x Legacy Premium Help
    Replies: 22
    Last Post: Feb 11, 2011, 2:46 PM
  5. [CLOSED] Disabling dates in DateField
    By daneel in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 07, 2011, 12:01 PM

Tags for this Thread

Posting Permissions