[CLOSED] Custom control extending DropDownField IE/Firefox

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Custom control extending DropDownField IE/Firefox

    We have a control extending DropDownField - it used as a picker for various type of items. After upgrading to 4.1, it stopped working altogether on IE, while on Firefox and Chrome it works every second time :) I'll focus on the IE not working for now. The picker shows a window. In IE it disappears after a couple of seconds. Why and how can we fix it?

    I've tried to remove as much code as possible, but it's still quite long.

    PickerField.cs

        [DefaultProperty( "Text" )]
        [ToolboxData( "<{0}:PickerField runat=server></{0}:PickerField>" )]
        public class PickerField : Ext.Net.DropDownField
        {
            [Browsable( true )]
            [DefaultValue( false )]
            [Category( "Behavior" )]
            public bool MultipleSelection
            {
                get;
                set;
            }
    
            [Browsable( true )]
            [DefaultValue( false )]
            [Category( "Behavior" )]
            public bool SetTextAsValue
            {
                get;
                set;
            }
    
            public PickerField()
            {
                Editable = true;
                EnforceMaxLength = true;
    
                SetTextAsValue = false;
            }
    
            Ext.Net.Window aWindowPicker;
    
            protected override void OnInit( EventArgs e )
            {
                this.Mode = DropDownMode.ValueText;
    
                Listeners.Expand.Handler = "this.picker.setWidth(570);";
                if ( IsRemoteValidation )
                {
                    Listeners.Blur.Handler = "this.remoteValidate();";
                }
    
    
                if ( !Editable && AllowBlank )
                {
                    FieldTrigger.Config aTriggerConfig = new FieldTrigger.Config();
                    aTriggerConfig.Icon = Ext.Net.TriggerIcon.Clear;
                    aTriggerConfig.QTip = "Clear";
                    Triggers.Add( new FieldTrigger( aTriggerConfig ) );
    
                    Listeners.TriggerClick.Handler = "this.clear();";
                }
    
                this.EnableKeyEvents = true;
                if ( MultipleSelection )
                {
                    Listeners.KeyUp.Handler = "item._value = '';";
                    Listeners.KeyUp.Buffer = 500;
                }
                else
                   if ( !MultipleSelection && SetTextAsValue )
                {
                    Listeners.KeyUp.Handler = "item._value = item.rawValue;";
                    Listeners.KeyUp.Buffer = 500;
                }
    
                aWindowPicker = new Ext.Net.Window();
                aWindowPicker.ID = this.ID + "_windowPicker";
                aWindowPicker.Modal = false;
                aWindowPicker.ButtonAlign = Ext.Net.Alignment.Right;
                aWindowPicker.Title = "Books";
                aWindowPicker.Layout = "FitLayout";
                aWindowPicker.Width = 570;
                aWindowPicker.Height = 370;
    
                aWindowPicker.Listeners.Close.Handler = string.Format( "#{{{0}}}.collapse();", this.ID );
    
                if ( MultipleSelection )
                {
                    StringBuilder aSB = new StringBuilder();
                    aSB.AppendFormat( "var result = #{{{0}}}.iframe.dom.contentWindow.GetPickerSelectedItems();#{{{1}}}.setValue(result.Value,result.Text);", aWindowPicker.ID, this.ID );
    
                    Ext.Net.Button btnOK = new Ext.Net.Button();
                    btnOK.Text = "OK";
                    btnOK.Listeners.Click.Handler = aSB.ToString();
                    btnOK.ID = this.ID + "_btnOK";
    
                    aWindowPicker.Buttons.Add( btnOK );
                }
    
                Ext.Net.Button aCloseButton = new Ext.Net.Button();
                aCloseButton.Text = "Close";
                aCloseButton.Listeners.Click.Handler = string.Format( "#{{{0}}}.collapse();", this.ID );
                aCloseButton.ID = this.ID + "_btnClose";
    
                aWindowPicker.Buttons.Add( aCloseButton );
    
                aWindowPicker.Loader = new Ext.Net.ComponentLoader();
                aWindowPicker.Loader.DisableCaching = false;
                aWindowPicker.Loader.Mode = Ext.Net.LoadMode.Frame;
                aWindowPicker.Loader.TriggerEvent = "show";
                aWindowPicker.Loader.ReloadOnEvent = true;
                aWindowPicker.Loader.LoadMask.ShowMask = true;
                aWindowPicker.Loader.LoadMask.Msg = "Loading";
                aWindowPicker.Loader.ID = this.ID + "_loader";
                aWindowPicker.Loader.Url = ResolveUrl( HttpUtility.UrlPathEncode( string.Format( "PickerTable.aspx?Type={0}&Multiple={1}&ParentControl={2}", "Books", MultipleSelection.ToString(), this.ID ) ) );
                aWindowPicker.Loader.IsDynamic = true;
    
                if ( MultipleSelection )
                {
                    aWindowPicker.Loader.Listeners.BeforeLoad.Handler = string.Format( "var initialValuesUrl = GetPickerInitialValuesUrl('{0}'); if(initialValuesUrl != null) options.url+='&'+initialValuesUrl;", this.ClientID.Remove( 0, 4 ) );
                }
    
                Component.Add( aWindowPicker );
    
                base.OnInit( e );
            }
    
            protected override void OnLoad( EventArgs e )
            {
                if ( !Page.IsPostBack )
                {
                    if ( string.IsNullOrEmpty( TriggerCls ) )
                    {
                        TriggerIcon = Ext.Net.TriggerIcon.SimpleMagnify;
                    }
                }
    
                base.OnLoad( e );
            }
        }
    PickerTable.aspx

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <ext:ResourceManager runat="server">
                </ext:ResourceManager>
                <ext:Hidden ID="edtParentControl" runat="server"></ext:Hidden>
                <ext:Viewport runat="server" Layout="BorderLayout">
                    <Items>
                        <ext:FieldSet runat="server" ID="fldSetSearch" Title="Search" Layout="FormLayout" Collapsible="false" Region="North" MarginSpec="0 5 0 5" PaddingSpec="0 5 5 5">
                            <Items>
                                <ext:FieldContainer runat="server" FieldLabel="Criteria">
                                    <LayoutConfig>
                                        <ext:HBoxLayoutConfig Align="Stretch"></ext:HBoxLayoutConfig>
                                    </LayoutConfig>
                                    <Items>
                                        <ext:SelectBox ID="cmbSearchCriteria" runat="server" MarginSpec="0 5 0 0" ForceSelection="True"></ext:SelectBox>
                                        <ext:TextField runat="server" ID="edtFilter" Flex="1" MaxLength="100" MarginSpec="0 5 0 0"></ext:TextField>
                                        <ext:Button runat="server" ID="btnSearch" Text="Search">
                                        </ext:Button>
                                    </Items>
                                </ext:FieldContainer>
                            </Items>
                            <KeyMap ID="KeyMap1" runat="server">
                                <Binding>
                                    <ext:KeyBinding Handler="#{btnSearch}.fireEvent('click')">
                                        <Keys>
                                            <ext:Key Code="ENTER" />
                                        </Keys>
                                    </ext:KeyBinding>
                                </Binding>
                            </KeyMap>
                        </ext:FieldSet>
                        <ext:GridPanel Frame="false" ID="gridItems" runat="server" Layout="FitLayout" Region="Center" EmptyText="NoDataFound">
                            <Store>
                                <ext:Store runat="server" AutoLoad="true" RemotePaging="true" RemoteSort="true" ID="storePicker">
                                    <Proxy>
                                        <ext:PageProxy>
                                        </ext:PageProxy>
                                    </Proxy>
                                    <Sorters>
                                        <ext:DataSorter Direction="ASC"></ext:DataSorter>
                                    </Sorters>
                                    <Model>
                                        <ext:Model runat="server" ID="modelPicker">
                                        </ext:Model>
                                    </Model>
                                </ext:Store>
                            </Store>
                            <View>
                                <ext:GridView runat="server" LoadingText="Loading"></ext:GridView>
                            </View>
                            <BottomBar>
                                <ext:PagingToolbar ID="PagingToolbar1" runat="server" HideRefresh="True" />
                            </BottomBar>
                        </ext:GridPanel>
                    </Items>
                </ext:Viewport>
            </div>
        </form>
    </body>
    </html>
    Last edited by fabricio.murta; Nov 01, 2016 at 7:32 PM.
  2. #2
    Hello Edgar!

    I don't see your ASPX code referencing to the PickerField component you created at any point. Besides, the ASPX page is throwing errors on load, as if something really basic is missing. Do you really need all this (fieldset with different fields, plus a grid with page proxy and remote sort, also a paging toolbar, and absolutely no data) to reproduce the issue?

    I'm a little clueless for where I should start looking for errors here... Maybe you can create a fresh Ext.NET project and try pasting your code there, see if it works. Also providing the namespaces you used on your class definition could be final in identifying any missing parts of the example.

    I was expecting to see something like:

    <%@ Register Namespace="My.Project.PickerField" TagPrefix="customPicker" %>
    and then

    <customPicker:PickerField ... />
    In your sample. But maybe there's a different approach you are using that I couldn't understand in your test case.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Yes, we need all that - that grid will load certain items. I did say we'll focus for now on the picker disappearing in IE as opposed to Firefox/Chrome.

    Fabricio, just add a simple aspx referencing that control, please. My apologies, I forgot to add it. I did create a separate project, just forgot to add the Default.aspx.

    <customPicker:PickerField runat="server" />
    The PickerTable.aspx is loaded by the PickerField. It's not my code, I just have to make it work :)
  4. #4
    Hello!

    I still can't get the sample to work. Can you provide the default.aspx code? Again, for such examples, how you are pulling the namespaces or defining the controls is important.
    Fabrício Murta
    Developer & Support Expert
  5. #5
    Here you go:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebAppTestPicker.Default" %>
    
    <%@ Register Assembly="WebAppTestPicker" Namespace="WebAppTestPicker" TagPrefix="custom" %>
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager runat="server" />
            <custom:PickerField ID="testpicker" runat="server" />
        </form>
    </body>
    </html>
  6. #6
    Hello Edgar!

    Sometimes registering a server-side control can be a headache!.. It only worked here once I either set it up from Web.config. And then I could make it work with another tag prefix not custom. Probably it required a Web.config change before it worked at all, and no project clean/rebuild/reopen worked at all. I remember having problems like that with server controls in the past and they worked just like the same: out of the blue.

    Once it works, fortunately, it does not seem to break again.

    Now to the brief part of the whole story.

    So much for a missing ID="<something>" in your custom control! :)

    Run your code with debug enabled on Visual Studio. You'll notice it will break in a strange way you can't really "break" at that point and investigate the code, but you can peek the window behind the error message and see it tries to call a #{}.collapse.

    If you search your code, you'll see it using this.ID to fill up this (lines 76 and 93 of your code). So give your custom control an ID and voila.

    <custom:PickerField ID="test" runat="server" />
    Well, anyway, this looks too easy to be true but at least at this point I can run the page. If that's still not the issue you are having, please let us know and give a step-by-step to reproduce the exact problem, and we'll try to fix what is not working there.

    I can have the sample show up consistently in IE.

    Just a suggestion, you could instead of this, maybe, refactor your control to use a proper .ascx file instead of redirecting to an .aspx from code behind. There are some limitations on server controls that work just fine in custom (.ascx) controls, and referencing them from the page (with Src= instead of Assembly=) seems to work much better and avoid headaches in the future.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  7. #7
    Hello Fabrício!

    I don't quite follow. You said I should add an ID, but the control already has one.

    The window does appear in IE, but disappears after 3 to 5 seconds. This doesn't happen in Chrome/Firefox.

    As far as I can tell, the collapse event is not triggered, however the hide event is. Apparently the call stack contains a onFocusLeave for the "testpicker".
  8. #8
    Yes, it was too easy to be true, sorry. First time you suggested how to use the control you didn't specify an ID. I got a problem down to a sorter here, investigating. Will get back to you soon.
    Fabrício Murta
    Developer & Support Expert
  9. #9
    Hello again, Edgar!

    Please review and clean up your test case example, it has several artifacts that breaks or are not necessary to reproduce the issue. I still can't run it at all.

    To the point I've shared above, all I could do is make the field with the trigger show up, but when I open the window from the trigger field, I am getting errors. Maybe you don't even need the fields inside the window in order to reproduce what really is your problem.

    Try removing stuff from the page and reproducing the issue, until you get to a point with the fewest artifacts in the window that still reproduces the issue.

    If we don't clean it up, we will just be finding errors that are not related to what you really need fixed. I still am not sure what the problem actually is there. Maybe I'm missing some steps, a step by step to reproduce the behavior might help too.

    Sorry to insist on this, we really want to help, but we will probably be just be posting back misleading responses until the exact issue is clearly reproducible in our end. Hope you understand.
    Fabrício Murta
    Developer & Support Expert
  10. #10
    Hi Fabrício!

    You mention some errors, but you don't go into specifics. It would be really helpful if you would share with me some details regarding those errors. [I get no errors]

    The project contains 3 files (Default.aspx, PickerField.cs and PickerTable.aspx). The code-behind for both aspx files is empty (just the class declaration, no method, no properties).

    I have removed the grid and it still happens.

    Please review the code below - perhaps I'm missing something very basic. Thank you!

    WebAppTestPicker.csproj

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
      <Import Project="..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" />
      <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <ProductVersion>
        </ProductVersion>
        <SchemaVersion>2.0</SchemaVersion>
        <ProjectGuid>{2F3C1242-7DEF-4438-B078-CD924A202764}</ProjectGuid>
        <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <RootNamespace>WebAppTestPicker</RootNamespace>
        <AssemblyName>WebAppTestPicker</AssemblyName>
        <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
        <UseIISExpress>true</UseIISExpress>
        <IISExpressSSLPort />
        <IISExpressAnonymousAuthentication />
        <IISExpressWindowsAuthentication />
        <IISExpressUseClassicPipelineMode />
        <UseGlobalApplicationHostFile />
        <NuGetPackageImportStamp>
        </NuGetPackageImportStamp>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>bin\</OutputPath>
        <DefineConstants>DEBUG;TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
        <DebugType>pdbonly</DebugType>
        <Optimize>true</Optimize>
        <OutputPath>bin\</OutputPath>
        <DefineConstants>TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
      </PropertyGroup>
      <ItemGroup>
        <Content Include="packages.config" />
        <None Include="Web.Debug.config">
          <DependentUpon>Web.config</DependentUpon>
        </None>
        <None Include="Web.Release.config">
          <DependentUpon>Web.config</DependentUpon>
        </None>
      </ItemGroup>
      <ItemGroup>
        <Content Include="Default.aspx" />
        <Content Include="PickerTable.aspx" />
        <Content Include="Web.config" />
      </ItemGroup>
      <ItemGroup>
        <Compile Include="Default.aspx.cs">
          <DependentUpon>Default.aspx</DependentUpon>
          <SubType>ASPXCodeBehind</SubType>
        </Compile>
        <Compile Include="Default.aspx.designer.cs">
          <DependentUpon>Default.aspx</DependentUpon>
        </Compile>
        <Compile Include="PickerField.cs" />
        <Compile Include="PickerTable.aspx.cs">
          <DependentUpon>PickerTable.aspx</DependentUpon>
          <SubType>ASPXCodeBehind</SubType>
        </Compile>
        <Compile Include="PickerTable.aspx.designer.cs">
          <DependentUpon>PickerTable.aspx</DependentUpon>
        </Compile>
        <Compile Include="Properties\AssemblyInfo.cs" />
      </ItemGroup>
      <PropertyGroup>
        <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
        <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
      </PropertyGroup>
      <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
      <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
      <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />
      <ProjectExtensions>
        <VisualStudio>
          <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
            <WebProjectProperties>
              <UseIIS>True</UseIIS>
              <AutoAssignPort>True</AutoAssignPort>
              <DevelopmentServerPort>58909</DevelopmentServerPort>
              <DevelopmentServerVPath>/</DevelopmentServerVPath>
              <IISUrl>http://localhost:58909/</IISUrl>
              <NTLMAuthentication>False</NTLMAuthentication>
              <UseCustomServer>False</UseCustomServer>
              <CustomServerUrl>
              </CustomServerUrl>
              <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
            </WebProjectProperties>
          </FlavorProperties>
        </VisualStudio>
      </ProjectExtensions>
      <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
        <PropertyGroup>
          <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
        </PropertyGroup>
        <Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.1.0.0\build\Microsoft.Net.Compilers.props'))" />
        <Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
      </Target>
      <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
           Other similar extension points exist, see Microsoft.Common.targets.
      <Target Name="BeforeBuild">
      </Target>
      <Target Name="AfterBuild">
      </Target>
      -->
    </Project>
    Web.config

    <?xml version="1.0" encoding="utf-8"?>
    <!--
      For more information on how to configure your ASP.NET application, please visit
      http://go.microsoft.com/fwlink/?LinkId=169433
      -->
    <configuration>
      <configSections>
        <section name="extnet" type="Ext.Net.GlobalConfig" requirePermission="false" />
      </configSections>
      <system.web>
        <compilation debug="true" targetFramework="4.5.2" />
        <httpRuntime targetFramework="4.5.2" />
        <pages>
          <controls>
            <add assembly="Ext.Net" namespace="Ext.Net" tagPrefix="ext" />
          </controls>
          <namespaces>
            <add namespace="Ext.Net" />
          </namespaces>
        </pages>
      </system.web>
      <system.codedom>
        <compilers>
          <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:6 /nowarn:1659;1699;1701" />
          <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.CodeDom.Providers.DotNetCompilerPlatform.VBCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" warningLevel="4" compilerOptions="/langversion:14 /nowarn:41008 /define:_MYTYPE=\&quot;Web\&quot; /optionInfer+" />
        </compilers>
      </system.codedom>
      <extnet theme="Triton" licenseKey="** Ext.NET LICENSE KEY HERE **" initScriptMode="Linked" />
      <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
        <handlers>
          <add name="DirectRequestHandler" verb="*" path="*/ext.axd" preCondition="integratedMode" type="Ext.Net.ResourceHandler" />
        </handlers>
        <modules>
          <add name="DirectRequestModule" preCondition="managedHandler" type="Ext.Net.DirectRequestModule, Ext.Net" />
        </modules>
      </system.webServer>
    </configuration>
    Default.aspx

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebAppTestPicker.Default" %>
    
    <%@ Register Assembly="WebAppTestPicker" Namespace="WebAppTestPicker" TagPrefix="custom" %>
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager runat="server" />
            <custom:PickerField ID="testpicker" runat="server" />
        </form>
    </body>
    </html>
    PickerField.aspx

    using Ext.Net;
    using System;
    using System.ComponentModel;
    using System.Text;
    using System.Web;
    using System.Web.UI;
    
    namespace WebAppTestPicker
    {
        [DefaultProperty( "Text" )]
        [ToolboxData( "<{0}:PickerField runat=server></{0}:PickerField>" )]
        public class PickerField : DropDownField
        {
            [Browsable( true )]
            [DefaultValue( false )]
            [Category( "Behavior" )]
            public bool MultipleSelection
            {
                get;
                set;
            }
    
            [Browsable( true )]
            [DefaultValue( false )]
            [Category( "Behavior" )]
            public bool SetTextAsValue
            {
                get;
                set;
            }
    
            public PickerField()
            {
                Editable = true;
                EnforceMaxLength = true;
    
                SetTextAsValue = false;
            }
    
            Window aWindowPicker;
    
            protected override void OnInit( EventArgs e )
            {
                Mode = DropDownMode.ValueText;
    
                Listeners.Expand.Handler = "this.picker.setWidth(570);";
                if ( IsRemoteValidation )
                {
                    Listeners.Blur.Handler = "this.remoteValidate();";
                }
    
                if ( !Editable && AllowBlank )
                {
                    FieldTrigger.Config aTriggerConfig = new FieldTrigger.Config();
                    aTriggerConfig.Icon = TriggerIcon.Clear;
                    aTriggerConfig.QTip = "Clear";
                    Triggers.Add( new FieldTrigger( aTriggerConfig ) );
    
                    Listeners.TriggerClick.Handler = "this.clear();";
                }
    
                EnableKeyEvents = true;
                if ( MultipleSelection )
                {
                    Listeners.KeyUp.Handler = "item._value = '';";
                    Listeners.KeyUp.Buffer = 500;
                }
                else
                   if ( !MultipleSelection && SetTextAsValue )
                {
                    Listeners.KeyUp.Handler = "item._value = item.rawValue;";
                    Listeners.KeyUp.Buffer = 500;
                }
    
                aWindowPicker = new Window();
                aWindowPicker.ID = ID + "_windowPicker";
                aWindowPicker.Modal = false;
                aWindowPicker.ButtonAlign = Alignment.Right;
                aWindowPicker.Title = "Books";
                aWindowPicker.Layout = "FitLayout";
                aWindowPicker.Width = 570;
                aWindowPicker.Height = 370;
    
                aWindowPicker.Listeners.Close.Handler = string.Format( "#{{{0}}}.collapse();", ID );
    
                if ( MultipleSelection )
                {
                    StringBuilder aSB = new StringBuilder();
                    aSB.AppendFormat( "var result = #{{{0}}}.iframe.dom.contentWindow.GetPickerSelectedItems();#{{{1}}}.setValue(result.Value,result.Text);", aWindowPicker.ID, ID );
    
                    Button btnOK = new Button();
                    btnOK.Text = "OK";
                    btnOK.Listeners.Click.Handler = aSB.ToString();
                    btnOK.ID = this.ID + "_btnOK";
    
                    aWindowPicker.Buttons.Add( btnOK );
                }
    
                Button aCloseButton = new Button();
                aCloseButton.Text = "Close";
                aCloseButton.Listeners.Click.Handler = string.Format( "#{{{0}}}.collapse();", ID );
                aCloseButton.ID = ID + "_btnClose";
    
                aWindowPicker.Buttons.Add( aCloseButton );
    
                aWindowPicker.Loader = new ComponentLoader();
                aWindowPicker.Loader.DisableCaching = false;
                aWindowPicker.Loader.Mode = LoadMode.Frame;
                aWindowPicker.Loader.TriggerEvent = "show";
                aWindowPicker.Loader.ReloadOnEvent = true;
                aWindowPicker.Loader.LoadMask.ShowMask = true;
                aWindowPicker.Loader.LoadMask.Msg = "Loading";
                aWindowPicker.Loader.ID = ID + "_loader";
                aWindowPicker.Loader.Url = ResolveUrl( HttpUtility.UrlPathEncode( string.Format( "PickerTable.aspx?Type={0}&Multiple={1}&ParentControl={2}", "Books", MultipleSelection.ToString(), ID ) ) );
                aWindowPicker.Loader.IsDynamic = true;
    
                Component.Add( aWindowPicker );
    
                base.OnInit( e );
            }
    
            protected override void OnLoad( EventArgs e )
            {
                if ( !Page.IsPostBack )
                {
                    if ( string.IsNullOrEmpty( TriggerCls ) )
                    {
                        TriggerIcon = TriggerIcon.SimpleMagnify;
                    }
                }
    
                base.OnLoad( e );
            }
        }
    }
    PickerTable.aspx

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PickerTable.aspx.cs" Inherits="WebAppTestPicker.PickerTable" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <ext:ResourceManager runat="server" />
                <ext:Hidden ID="edtParentControl" runat="server"></ext:Hidden>
                <ext:Viewport runat="server" Layout="BorderLayout">
                    <Items>
                        <ext:FieldSet runat="server" ID="fldSetSearch" Title="Search" Layout="FormLayout" Collapsible="false" Region="North" MarginSpec="0 5 0 5" PaddingSpec="0 5 5 5">
                            <Items>
                                <ext:FieldContainer runat="server" FieldLabel="Criteria">
                                    <LayoutConfig>
                                        <ext:HBoxLayoutConfig Align="Stretch"></ext:HBoxLayoutConfig>
                                    </LayoutConfig>
                                    <Items>
                                        <ext:SelectBox ID="cmbSearchCriteria" runat="server" MarginSpec="0 5 0 0" ForceSelection="True"></ext:SelectBox>
                                        <ext:TextField runat="server" ID="edtFilter" Flex="1" MaxLength="100" MarginSpec="0 5 0 0"></ext:TextField>
                                        <ext:Button runat="server" ID="btnSearch" Text="Search">
                                        </ext:Button>
                                    </Items>
                                </ext:FieldContainer>
                            </Items>
                        </ext:FieldSet>
                    </Items>
                </ext:Viewport>
            </div>
        </form>
    </body>
    </html>
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 6
    Last Post: Dec 24, 2014, 9:37 AM
  2. [CLOSED] Extending Ext.net Control / Creating Custom Control
    By ljankowski in forum 2.x Premium Help
    Replies: 1
    Last Post: Dec 01, 2014, 6:52 PM
  3. Replies: 7
    Last Post: Sep 12, 2011, 2:58 PM
  4. [CLOSED] Possible to Extending Custom Search Combo Box
    By rbarr in forum 1.x Premium Help
    Replies: 3
    Last Post: Jul 01, 2011, 1:39 PM
  5. Extending Ext.Net.TextField Control
    By David Pelaez in forum 1.x Help
    Replies: 1
    Last Post: Dec 22, 2010, 10:43 AM

Tags for this Thread

Posting Permissions