Forums

Script returning NULL or undefined when doing callback

Last post 12/8/2008 7:23 AM by Roma R (DevExpress). 1 replies.
Sort Posts: Previous Next
  • David Terry_1

    Script returning NULL or undefined when doing callback

    12/5/2008 2:38 PM
    • Not Ranked
    • Joined on 12/4/2008
    • Posts 8

     I am trying to kick off the callback panel when a textbox looses focus but whenever the event is fired I get undefined or null for the return value of the textbox.value.  Here is the code:

    <dxe:ASPxTextBox ID="DriverCodeTxt" runat="server" Width="170px"
                ClientInstanceName="DriverCodeTxt" EnableClientSideAPI="True">
                <ClientSideEvents LostFocus="function(s, e) {
      var targetElement = document.getElementById('DriverCodeTxt');
      CallbackPanel.PerformCallback(targetElement.getAttribute('Value')); // I've also tried targetElement.value which returns undefined
    }" />
            </dxe:ASPxTextBox>
            <dxcp:ASPxCallbackPanel ID="CallbackPanel" runat="server" Height="87px" Width="782px"
                ClientInstanceName="CallbackPanel" OnCallback="CallbackPanel_Callback">
                <PanelCollection>
                    <dxrp:PanelContent runat="server">
                        <asp:Label ID="Label3" runat="server" Text="Security Question: "></asp:Label><asp:Label
                            ID="QuestionLbl" runat="server" Text=""></asp:Label><br />
                        <asp:Label ID="Label2" runat="server" Text="Answer: "></asp:Label>
                        <asp:TextBox ID="AnswerTxt" runat="server" Width="380px"></asp:TextBox><br />
                        <br />
                        <asp:Button ID="SubmitBtn" runat="server" Text="Submit" />
                    </dxrp:PanelContent>
                </PanelCollection>
            </dxcp:ASPxCallbackPanel>

    protected void  CallbackPanel_Callback(object source, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
        {
            SqlConnection sqlCnn = new SqlConnection(ConfigurationManager.ConnectionStrings["driverportalConnectionString2"].ConnectionString);

            sqlCnn.Open();
            SqlCommand sqlCmd = new SqlCommand();
            sqlCmd.Connection = sqlCnn;

            if (DriverCodeTxt.Text.Length > 0)
            {
                sqlCmd.CommandText = "select * from [Security] where [User] = '" + e.Parameter.ToString().ToUpper() + "'";
                sqlRdr = sqlCmd.ExecuteReader();

                if (sqlRdr.HasRows)
                {
                    QuestionLbl.Text = sqlRdr["Question"].ToString();
                }
                else
                {
                    lblStatus.Text = "User doesn't exist.";
                }
            }
        }

  • Roma R (DevExpress)

    Re: Script returning NULL or undefined when doing callback

    12/8/2008 7:23 AM
    • Top 50 Contributor
    • Joined on 5/4/2007
    • Posts 486

    Hello David,

    You should replace the following code

    var targetElement = document.getElementById('DriverCodeTxt');
    CallbackPanel.PerformCallback(targetElement.getAttribute('Value'));

    with

    CallbackPanel.PerformCallback(DriverCodeTxt.GetValue());

    Thanks, Roman
    R&D, .Net Team, DevExpress

    PS. If you wish to receive direct assistance from our Support Team, use Support Center.
More from DevExpress
Live Chat
Have a pre-sales question?
Need assistance with your evaluation?
We are here to help.
Chat is one of the many ways you can contact members of the DevExpress Team. We are available Monday-Friday between 8:30am and 5:00pm Pacific Time.
If you need additional product information, require pre-sales assistance, or want help with your order, write to us at info@devexpress.com or call us at
+1 (818) 844-3383.