1

如果失去焦点,我正在使用 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 

4

0 回答 0