Blur Listener - setValue on Textfield not working?

  1. #1

    Blur Listener - setValue on Textfield not working?

    I have the below - when I attempt to set a textfield via setValue on a listener handler/blur - not working - the textfield is not picking up the array value from th JS - from the split() funtion - txtWordOne is not picking up the value?
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Hospitals_To_Peer_Groups.aspx.cs"
        Inherits="PARA_Staff_Only_Projects._Default" Debug="true" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <style type="text/css">
            .txt-bold
            {
                font-family: verdana;
                font-weight: bold;
                font-size: 10px;
                color: #333333;
            }
            .txt-normal
            {
                font-family: verdana;
                font-weight: normal;
                font-size: 10px;
                color: #333333;
            }
            .txt-normal2 .x-form-field
            {
                font-family: verdana;
                font-weight: normal;
                font-size: 10px;
                color: #333333;
            }
        </style>
        <script type="text/javascript">
            function split() {
                var s = "This is a test", a = s.split(' ');
                alert(a[0]);
                txtWordOne.setValue(a[0]);
                //document.write(a1.join(" <br> "));
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" Theme="Default" />
        <ext:Hidden runat="server" ID="hdnDB" />
        <div style="padding-left: 40px; padding-top: 40px;">
            <table border="0" cellpadding="4" cellspacing="0" style="width: 640px;">
                <tr>
                    <td style="width: 100px;">
                        <div class="txt-bold">
                            Provider ID:</div>
                        <ext:TextField ID="txtProvID" runat="server" Width="90" Cls="txt-normal2" />
                    </td>
                    <td style="width: 310px;">
                        <div class="txt-bold">
                            Full Name:</div>
                        <ext:TextField ID="txtFullName" runat="server" Width="300" Cls="txt-normal2">
                            <Listeners>
                                <Blur Handler="split();" />
                            </Listeners>
                        </ext:TextField>
                    </td>
                    <td>
                        <div class="txt-bold">
                            Zip Code:</div>
                        <ext:TextField ID="txtZipCode" runat="server" Width="60" Cls="txt-normal2">
                            <Listeners>
                                <%--Hacky workaround - but Blur event is not working with Ext.Net's latest build--%>
                                <Blur Handler="btn.click();" />
                            </Listeners>
                        </ext:TextField>
                    </td>
                    <td valign="top" style="width: 110px;">
                        <div class="txt-bold" style="padding-bottom: 4px;">
                            City:</div>
                        <ext:Label Cls="txt-normal" runat="server" ID="lblCity" />
                    </td>
                    <td valign="top">
                        <div class="txt-bold" style="padding-bottom: 4px;">
                            State:</div>
                        <ext:Label Cls="txt-normal" runat="server" ID="lblState" />
                    </td>
                </tr>
            </table>
            <div>
                &nbsp;</div>
            <table border="0" cellpadding="4" cellspacing="0" style="width: 400px;">
                <tr>
                    <td>
                        <div class="txt-bold">
                            Word 1:</div>
                        <ext:TextField ID="txtWordOne" runat="server" Width="90" Cls="txt-normal2" />
                    </td>
                    <td>
                        <div class="txt-bold">
                            Word 2:</div>
                        <ext:TextField ID="txtWordTwo" runat="server" Width="90" Cls="txt-normal2" />
                    </td>
                    <td>
                        <div class="txt-bold">
                            Word 3:</div>
                        <ext:TextField ID="txtWordThree" runat="server" Width="90" Cls="txt-normal2" />
                    </td>
                    <td>
                        <div class="txt-bold">
                            Word 4:</div>
                        <ext:TextField ID="txtWordFour" runat="server" Width="90" Cls="txt-normal2" />
                    </td>
                </tr>
            </table>
            <ext:Button runat="server" ID="btn" Hidden="true">
                <DirectEvents>
                    <Click OnEvent="getCityAndSateByZip" Delay="200" />
                </DirectEvents>
            </ext:Button>
            <br />
        </div>
        </form>
    </body>
    </html>
  2. #2
    Hi,

    For me the work 'this' is in the alert when the "Full Name" field is blurred.

    Please post a simplified sample we can test with that reproduces the problem. There seems to be a lot of unrelated code in your original sample.
    Geoffrey McGill
    Founder & CEO
  3. #3
    That is the strange thing - the alert fires - but the textfield value never gets sets - and does not throw any errors
  4. #4
    Quote Originally Posted by Tbaseflug View Post
    That is the strange thing - the alert fires - but the textfield value never gets sets - and does not throw any errors
    For me the string "This" is set on the "Word 1" TextField.
    Geoffrey McGill
    Founder & CEO
  5. #5

    --

    Quote Originally Posted by Tbaseflug View Post
    That is the strange thing - the alert fires - but the textfield value never gets sets - and does not throw any errors
    Try putting the variable 'a' on a separate line and access the first element of the array directly. Sounds weird but I've seen this problem before.
    If that doesn't work then try putting a hard coded value in the setValue method to make sure it's not something else. Also, how do you know for sure
    there are no errors, I don't see a try catch block in your javascript function?

    try
    {
    var a = s.split(' ')[0];
    txtWordOne.setValue(a);
    
    //txtWordOne.setValue('just a hardcoded test');
    }
    catch (err)
    {
    alert(err);
    }
    Last edited by geoffrey.mcgill; Jul 01, 2012 at 5:26 AM. Reason: please use [CODE] tags

Similar Threads

  1. [CLOSED] TextField: Help with Remove SelectedText on Blur event
    By nhg_itd in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 31, 2012, 1:12 AM
  2. [CLOSED] TextField Blur event is throwing error in Editable Grid
    By rnachman in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jan 05, 2012, 4:25 PM
  3. TextField DirectEvent Blur Error
    By David Pelaez in forum 1.x Help
    Replies: 5
    Last Post: Dec 21, 2010, 12:32 PM
  4. Textfield Keyup Listener Not Working
    By Tbaseflug in forum 1.x Help
    Replies: 1
    Last Post: Sep 25, 2009, 2:10 AM
  5. [CLOSED] validate textfield on blur
    By idrissb in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 29, 2009, 3:47 PM

Posting Permissions