[CLOSED] EmptyText is being returned as ctl.Text value to DirectEvent under IE, not Chrome or FF.

  1. #1

    [CLOSED] EmptyText is being returned as ctl.Text value to DirectEvent under IE, not Chrome or FF.

    This one is hard to reproduce in a sample but appears in IE consistently on my website. It's affecting a DirectEvent and returning the EmptyText value instead of it's current value in one of my controls on my website. You can reproduce it here: www.scenecalendar.com. First thing you should do is click to set focus into "Click for County" ComboBox, it calls a DirectEvent that databinds to the County store. In that DirectEvent it reads the value of State.Text to determine the where clause into the database. The problem is State.Text is the EmptyText instead of the empty value. This only happens in IE and does not happen in either Chrome or FF. State.Text populates correctly in those browsers.

    Here's the request body from IE that reveals the issue. Again, you should be able to reproduce it. Search for ctl00_cp_ctl05_ctl01_State=Specify%20State
    submitDirectEventConfig=%7B%22config%22%3A%7B%22viewStateMode%22%3A%22enabled%22%7D%7D&ctl00_Login_UN=Login%20Name&ctl00_Login_PW=Password&ctl00_cp_Adult=App.ctl00_cp_Adult&ctl00_cp_vTabs=ctl00_cp_vTabs%3A0&ctl00_cp_ctl05_ctl01_Zip=ZipCode&ctl00_cp_ctl05_ctl01_County=&_ctl00_cp_ctl05_ctl01_County_state=&ctl00_cp_ctl05_ctl01_State=Specify%20State&_ctl00_cp_ctl05_ctl01_State_state=&ctl00_cp_ctl05_ctl11_GTagP_ActiveTab=portalpanel-1019%3A0&ctl00_cp_ctl05_ctl11_GTagP_ActiveGroup=panel-1018%3A0&__EVENTTARGET=ctl00%24rm%24rm&__EVENTARGUMENT=ctl00_cp_ctl05_ctl01_County%7Cevent%7CFocus&__VIEWSTATE=... &__EVENTVALIDATION=3JgJMcbguvK2pc6ILot2Ftt0NKQVoPXXG0iDnFu1ZxPIw1K5ic4G68g74rV01uJi5IUPAY2pu8A0RJXpVxIsULRTKyYSCyX1W41NiOVbi4WHKCq0
    The same request body in Chrome:
    submitDirectEventConfig=%7B%22config%22%3A%7B%22viewStateMode%22%3A%22enabled%22%7D%7D&ctl00_Login_UN=&ctl00_Login_PW=&ctl00_cp_Adult=App.ctl00_cp_Adult&ctl00_cp_vTabs=ctl00_cp_vTabs%3A0&ctl00_cp_ctl05_ctl01_Zip=&ctl00_cp_ctl05_ctl01_County=&_ctl00_cp_ctl05_ctl01_County_state=&ctl00_cp_ctl05_ctl01_State=&_ctl00_cp_ctl05_ctl01_State_state=&ctl00_cp_ctl05_ctl11_GTagP_ActiveTab=portalpanel-1019%3A0&ctl00_cp_ctl05_ctl11_GTagP_ActiveGroup=panel-1018%3A0&__EVENTTARGET=ctl00%24rm%24rm&__EVENTARGUMENT=ctl00_cp_ctl05_ctl01_County%7Cevent%7CFocus&__VIEWSTATE=...
    &__EVENTVALIDATION=i6ROtwU%2FHipMNm2sZmYzJ7DZ%2BwhsoLec02uDqAJUlrj2uOcCT4LxmwLMoMe1%2F7Bbd2mpkKe3%2F39Zr9yg%2F7g%2FxS4PUSxiRs%2FmXBdXafE3gh95Ir8j
    Last edited by Daniil; Mar 07, 2014 at 9:45 AM. Reason: [CLOSED]
  2. #2
    IE (versions<10) doesn't support HTML5 placeholders therefore ExtJS emulates it by adding text directly to the input element of field.
    Therefore that emptyText is submitted to the server when you use html form submit. It is expected behaviour. On the server side we compare submitted text with EmptyText property and ignore such value

    If you want to exclude it then need to use FormPanel (FormPanel managed submit or set FormID for direct event)
    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    
    <!DOCTYPE html>
    
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    
    
        <script runat="server">
            protected void Submit_Event(object sender, DirectEventArgs e)
            {
                X.Js.Alert("Request value: " + Request[TextField1.UniqueID]);
                X.Js.Alert("Field value: " + TextField1.Text);
            }
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            
            <ext:FormPanel ID="FormPanel1" runat="server">
                <Items>
                    <ext:TextField ID="TextField1" runat="server" EmptyText="Empty" />
                </Items>
                <Buttons>
                    <ext:Button runat="server" Text="Submit">
                        <DirectEvents>
                            <Click OnEvent="Submit_Event" FormID="#({return #{FormPanel1};})" />
                        </DirectEvents>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
        </form>
    </body>
    </html>
  3. #3
    Okay, I get where you're going, but what I do not understand is why extjs does not detect on the client side if (IE10 and text==emptyText) set text='' (or have an attribute to trigger this test in case the empty text is a valid value) before constructing the request body? Moreover, extnet on the serverside in postback can do the same test in the .Text get property. I realize that EmptyText can be assigned dynamically and is not guaranteed but that's just a postback chronological paradigm. There's got to be a better answer towards bulletproofing from you guys than, "well, do it yourself."

    I will of course do as you ask... but this is one of those bugs that comes back to haunt developers when they need to change the EmptyText on the presentation side and easily forget that you have to match all the cases in the code too. Too easy to return a bug back to the surface.

    Are you sure you don't want to override Text in TextFieldBase? or the extjs clientside to address the problem universally and consistency?



    And for my instance, can I use your solution with FormID in the DirectEvent of a Focus for one of the form's controls (ie. not the button in the form)? I do actually need the value of the Text in another control when there is a value present. I just need it to be empty when it's matching the EmptyText. I think the better solution would be to set the text to empty if it matches the EmptyText in the Before of the DirectEvent. I still think you guys should have a more thorough implementation in the library.
  4. #4
    DirectEvent (ExtJS ajax request) just submit html form, it doesn't know about any components, it just search html input elemnts in the html form and submit its values. Threfore it cannot compare value with empty text because it operates with dom elements. It is like if you use asp.net button which causes hard postback, it submits html form dom elements also and know nothing about ExtJS fields.

    FormPanel works directly with ExtJS fields therefore it can remove emptyText from submit. Therefore the single way to use FormPanel instead html form

    Are you sure you don't want to override Text in TextFieldBase?
    I am not sure that correctly understood you. We ignore value from submit if the value equals EmptyText already
  5. #5
    Quote Originally Posted by Vladimir View Post
    I am not sure that correctly understood you.
    For instance, the following solved all my DirectEvent problems in all TextfieldBase controls in IE10 by modifying TextFieldBase whether in FormPanels or not.
            public virtual string Text
            {
                get
                {
                    object val = this.Value;
                    string str = (val == null) ? string.Empty : this.Value.ToString();
            return str.Equals( this.EmptyText ) ? string.Empty : str;
                }
                set
                {
                    this.Value = value == "" ? null : value;
                }
            }
    Quote Originally Posted by Vladimir View Post
    We ignore value from submit if the value equals EmptyText already
    Okay, so if I understand you, that's why you suggested I wrap my controls in another layer in a FormPanel and set the FormID.

    Quote Originally Posted by Vladimir View Post
    DirectEvent (ExtJS ajax request) just submit html form, it doesn't know about any components, it just search html input elemnts in the html form and submit its values. Threfore it cannot compare value with empty text because it operates with dom elements. It is like if you use asp.net button which causes hard postback, it submits html form dom elements also and know nothing about ExtJS fields.

    FormPanel works directly with ExtJS fields therefore it can remove emptyText from submit. Therefore the single way to use FormPanel instead html form
    I'd pose the solution here to be in the ext.net wrapper code before it calls the submit. For instance, like after you call before or confirm prompts. So for instance, it would be possible to set all text controls with values matching emptytext to '' before the actual submit. The dom elements would have the right values thanks to the client-side. I've solved other problems this way. Still this idea might not work because when the page comes back after the update, these same controls would have to be set back to their emptytext. A X.cleanup or some other function would have to be appended at the end of the responsebody.

    If you have a way to communicate up to ext.net in a secure fashion, I can think of a thousand other things that ext.net would be able to do that I've only been dreaming of.

    Anyway, thank you for entertaining the ideas. I look forward to your thoughts.
    Last edited by michaeld; Nov 05, 2013 at 12:43 PM.
  6. #6
    @michaeld, please clarify are you saying that a TextField.Text returns the empty text under IE10?

    I cannot reproduce it with this example. The alert box is empty.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Submit(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("Submit", this.TextField1.Text).Show();
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:TextField ID="TextField1" runat="server" EmptyText="Some EmptyText" />
    
            <ext:Button runat="server" Text="Submit" OnDirectClick="Submit" />
        </form>
    </body>
    </html>
  7. #7
    This is an older topic so if memory serves, I believe the situation is specific to inside a formpanel (which is why Vladimir posed I use a FormID to address).
  8. #8
    Well, Vladimir demonstrated how to avoid submitting EmptyText using a FormPanel.

    But I want to understand the initial issue which you stated in the original post.

    You stated that
    It's affecting a DirectEvent and returning the EmptyText value instead  of it's current value in one of my controls on my website.
    Could you, please, provide a sample how we can reproduce it?
  9. #9
    Go ahead and close this one. If I can find this issue again, I'll let you know. But at some point I changed my code, or hacked something that worked around the problem because I needed a solution to get the project to production at the time. I may have the issue in the version control history, but things are transitional right now and I can't access it.

Similar Threads

  1. Replies: 15
    Last Post: Oct 29, 2013, 11:45 AM
  2. Replies: 2
    Last Post: Nov 09, 2012, 3:23 PM
  3. Replies: 1
    Last Post: Apr 30, 2012, 5:16 PM
  4. EmptyText coming across as Text
    By dbassett74 in forum 1.x Help
    Replies: 6
    Last Post: Feb 12, 2011, 1:59 PM
  5. Replies: 7
    Last Post: May 09, 2009, 8:06 AM

Posting Permissions