How to enable view state for direct event?

  1. #1

    How to enable view state for direct event?

    Hi,

    Here is my code:

    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
        <ext:ResourceManager runat="server" ViewStateMode="Enabled" />
        <ext:FormPanel EnableViewState="true" ViewStateMode="Enabled" runat="server">
            <Buttons>
                <ext:Button ID="SendUserName" Text="Send" runat="server" >
                    <DirectEvents>
                        <Click OnEvent="SendUserName_DirectClick" />
                    </DirectEvents>
                </ext:Button>
            </Buttons>
            <Items>
                <ext:HBoxLayout runat="server">
                    <BoxItems>
                        <ext:BoxItem>
                            <ext:TextField ID="UserName" runat="server" />
                        </ext:BoxItem>
                        <ext:BoxItem>
                            <ext:Label ID="InfoLabel" runat="server" Text="" />
                            </ext:BoxItem>
                    </BoxItems>
                </ext:HBoxLayout>
            </Items>
        </ext:FormPanel>
    </asp:Content>
        public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
            }
    
            protected void SendUserName_DirectClick(object sender, DirectEventArgs e)
            {
                InfoLabel.Text = "User name set: " + (UserName.Text ?? "(no info)");
            }
        }
    My problem: UserName.Text always equals "" (empty string). How to change this (enable view state)?
  2. #2
    Hi galuset,

    You can set ViewStateMode="Enabled" on the DirectEvent config.

    Example

    <Click ViewStateMode="Enabled" OnEvent="SendUserName_DirectClick" />
    Hope this helps.
    Geoffrey McGill
    Founder & CEO
  3. #3
    Unfortunately this didn't help :(

    Here is how my code looks like.

    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
        <ext:ResourceManager ID="ResourceManager1" runat="server" ViewStateMode="Enabled" />
        <ext:FormPanel ID="FormPanel1" EnableViewState="true" ViewStateMode="Enabled" runat="server">
            <Buttons>
                <ext:Button ID="SendUserName" Text="Send" runat="server" >
                    <DirectEvents>
                        <Click ViewStateMode="Enabled" OnEvent="SendUserName_DirectClick" />
                    </DirectEvents>
                </ext:Button>
            </Buttons>
            <Items>
                <ext:HBoxLayout ID="HBoxLayout1" runat="server">
                    <BoxItems>
                        <ext:BoxItem>
                            <ext:TextField ID="UserName" runat="server" />
                        </ext:BoxItem>
                        <ext:BoxItem>
                            <ext:Label ID="InfoLabel" runat="server" Text="" />
                            </ext:BoxItem>
                    </BoxItems>
                </ext:HBoxLayout>
            </Items>
        </ext:FormPanel>
    </asp:Content>
    Maybe something is wrong with my Site.Master or Web.config...

    Site.Master
    <%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="ColliteTest.SiteMaster" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head runat="server">
        <title></title>
        <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
        <asp:ContentPlaceHolder ID="HeadContent" runat="server">
        </asp:ContentPlaceHolder>
    </head>
    <body>
        <h1>Coolite test</h1>
        <hr />
        <asp:ContentPlaceHolder ID="MainContent" runat="server" />
    </body>
    </html>
    Web.config
    <?xml version="1.0"?>
    
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    
    <configuration>
      <connectionStrings>
        <add name="ApplicationServices"
             connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true"
             providerName="System.Data.SqlClient" />
      </connectionStrings>
    
      <system.web>
        <httpHandlers>
          <add path="*/ext.axd" verb="*" type="Ext.Net.ResourceHandler" validate="false"/>
        </httpHandlers>
    
        <httpModules>
          <add name="DirectRequestModule" type="Ext.Net.DirectRequestModule, Ext.Net" />
        </httpModules>
        
        <pages>
          <controls>
            <add tagPrefix="ext" namespace="Ext.Net" assembly="Ext.Net"/>
            <add tagPrefix="ext" namespace="Ext.Net.Utilities" assembly="Ext.Net"/>
          </controls>
        </pages>
        
        <compilation debug="true" targetFramework="4.0" />
    
        <authentication mode="Forms">
          <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
        </authentication>
    
        <membership>
          <providers>
            <clear/>
            <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices"
                 enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
                 maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
                 applicationName="/" />
          </providers>
        </membership>
    
        <profile>
          <providers>
            <clear/>
            <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/>
          </providers>
        </profile>
    
        <roleManager enabled="false">
          <providers>
            <clear/>
            <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
            <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
          </providers>
        </roleManager>
    
      </system.web>
    
      <system.webServer>
         <modules runAllManagedModulesForAllRequests="true"/>
      </system.webServer>
    </configuration>
  4. #4
    Works! I have changed ext:FormPanel to standard form.
  5. #5
    Hi galuset,

    Could you please share your codes? because I try to enabledviewstate, still doesn't work.

    Thank you.

Similar Threads

  1. Replies: 14
    Last Post: Mar 26, 2015, 10:22 AM
  2. [CLOSED] Output Cache issue with Direct Method / Direct Event
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 18
    Last Post: Mar 01, 2013, 5:03 AM
  3. Direct method and direct event over SSL?
    By dimitar in forum 1.x Help
    Replies: 0
    Last Post: Oct 08, 2011, 8:09 PM
  4. How to Use view state in coolite ajax events
    By kiran malgi in forum 1.x Help
    Replies: 1
    Last Post: Jul 28, 2010, 11:04 AM
  5. Replies: 3
    Last Post: Apr 20, 2010, 12:21 PM

Posting Permissions