+ Reply to Thread
Results 1 to 2 of 2

Thread: custom event handler to get a postback on text changed

  1. #1
    Junior Member
    Join Date
    Jun 2012
    Posts
    13

    custom event handler to get a postback on text changed

    I currently have a custom text box, it implements majority of the base implementations a normal text box has, by doing something like:

    public string Text
    {
    get { return customTextBox.Text; }
    set { customTextBox.Text = value; }
    }
    I now want to implement a custom event handler to get a postback on text changed. I currently am doing the following is this correct if not then how should I go about this:

    private static readonly object EventCustomTextChanged = new Object();

    public event EventHandler TextChanged
    {
    add
    {
    Events.AddHandler(EventCustomTextChanged, value);
    }
    remove
    {
    Events.RemoveHandler(EventCustomTextChanged, value);
    }
    }
    This implementation comes from: http://msdn.microsoft.com/en-us/libr...xtchanged.aspx
    Before someone says why don't you use the one thats already there, I will tell you it's not implented because this is a custom user control. I am trying to implement it.

  2. #2
    Junior Member
    Join Date
    Jun 2012
    Posts
    14
    Do it in this way
    public event EventHandler TextChanged
    {
    add { customTextBox.TextChanged += value; }
    remove { customTextBox.TextChanged -= value; }
    }
    Assuming that customTextBox is the System.Web.UI.WebControls.TextBox control.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts