in
Forums
Blogs
DevExpress.com
Client Center
Support Center
DevExpress Channel

Script returning NULL or undefined when doing callback

Last post 12/8/2008 7:23 AM by Roman R (Developer Express). 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 12/5/2008 2:38 PM

    Script returning NULL or undefined when doing callback

     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.";
                }
            }
        }

  • 12/8/2008 7:23 AM In reply to

    Re: Script returning NULL or undefined when doing callback

    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
    Developer Express Inc.

    PS. If you wish to receive direct assistance from our Support Team, use Support Center.
Page 1 of 1 (2 items)
Copyright © 1998-2009 Developer Express Inc.
ALL RIGHTS RESERVED