English 中文(简体)
处理和使用OnTextChange事件
原标题:Exposing and then using OnTextChange Event handler

相关问题: 在习俗文本Box上添加习俗

In the related question I asked how I could expose OnTextChange in my custom textbox control and we resolved it by:

public event EventHandler TextChanged
{
    add { customTextBox.TextChanged += value; }
    remove { customTextBox.TextChanged -= value; }
}

在实行控制时,我正在尝试使用像现在这样变形的活动:

    <uc:CustomTextBox ID="customTextBox"
                      runat="server"
                      OnTextChanged="CustomTextBox_OnTextChanged">
    </uc:CustomTextBox>

这似乎从来不是为了:

    protected void CustomTextBox_OnTextChanged(System.EventArgs e)
    {
     // Do something here
    }

或击中:

    protected void CustomTextBox_OnTextChanged(object sender, EventArgs e)
    {
     // Do something here
    }

我做了什么错误,我失踪了什么,这是我试图在这里做一切的最佳方式或共同做法?

最佳回答

页: 1 AutoPostBack=True 文本Box的财产。

如果你设计网络用户控制,那么就简单地界定了公共财产,以在用户控制代码中设定<代码>True/False价值的CustomTextB:

public   bool AutoPostBack
    {
        get
        {
            return CustomTextBox.AutoPostBack;
        }
        set
        {
            CustomTextbox.AutoPostBack = value;
        }
    }

If you are developing a custom web control then you can to override the AutoPostBack property for the customization. If you don t want to customize AutoPostBack property then don t override it.

如果你凌驾于自治财产,请援引超级类别违约执行。

public override  bool AutoPostBack
    {
        get
        {
            return base.AutoPostBack;
        }
        set
        {
            base.AutoPostBack = value;
        }
    }
问题回答

In order for OnTextChanged to fire, you need to specify AutoPostBack="true" on the TextBox.

在业余标记中:

<uc:CustomTextBox ID="customTextBox" runat="server" OnTextChanged="CustomTextBox_OnTextChanged" AutoPostBack="true"></uc:CustomTextBox>

海关数据系统用户控制编码背后:

public bool AutoPostBack 
{ 
    get 
    { 
        //the textbox in the user control
        return customTextBox.AutoPostBack; 
    } 
    set 
    { 
        customTextBox.AutoPostBack = value; 
    } 
}




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!