RadTextBox TextChanged事件仅触发一次

时间:2019-05-07 08:05:39

标签: c# asp.net telerik-ajax

我正在使用TextBox的OnTextChanged事件,如果它失去焦点,则会在后面运行代码,第一次加载页面时,它会触发后面的代码。但是,在第一次运行后台代码后,如果我返回到文本框并使其再次失去焦点,它不会再执行任何代码。每次失去焦点时,如何使文本框触发代码。

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <telerik:RadTextBox ID="uiToLocation" runat="server" Width="100%" AutoPostBack="true"
                    OnTextChanged="uiToLocation_Leave" EmptyMessage="<%$ Resources:ResourceHKEx,Arrive_To %>" />
            </ContentTemplate>
        </asp:UpdatePanel>

后面的代码,主要是aspx.cs

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using Telerik.Web.UI;


namespace WebHKEx
{
    public partial class FlightEdit : Web.CustomPage
    {

        protected void Page_Init(object sender, EventArgs e)
        {
            // initialize variables
            InitializeVariables();

            // permission checking
            VerifyUserPermissions(true);

            // initialize controls
            InitializeControls();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void Page_UnLoad(object sender, EventArgs e)
        {

        }        

    } // end class
} // end namespace

后面的代码在一个子控件cs文件中。

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;

namespace WebHKEx.WebControls
{
    public partial class UsageControl2SubControl1 : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Convert.ToBoolean(uiRemoved.Value))
            {
                this.Visible = false;
            }
        }

        protected void uiToLocation_Leave(object sender, EventArgs e)
        {
                uiDistance = "123";

        }
    }// end class
}// end namespace 

0 个答案:

没有答案