Textbox changed event is not firing in Composite control ....

3 posts, 0 answers
  1. Mayank
    Mayank avatar
    5 posts
    Member since:
    Jan 2014

    Posted 07 Mar 2014 Link to this post

    public RadGrid Grid = new RadGrid();
    private RadTextBox txtbox = new RadTextBox();
     
    protected override void CreateChildControls()
    {
    txtbox.TextChanged += new EventHandler(txtbox_TextChanged);
     
    Controls.Add(txtbox);
    Controls.Add(Grid);
    txtbox.AutoPostBack = true;
    txtbox.Attributes.Add("onkeyup","SendTextBox():");
     
    }
     
    protected override void OnPreRender(EventArgs e)
    {
    ClientScriptManager cs = Page.ClientScript;

    cs.RegisterStartupScript(this.GetType(), "SendTextBox", "setTimeout('__doPostBack(\'" + txtbox.ID + "\',\'\')', 0);", true);
    base.OnPreRender(e);
    }
     
    protected void txtbox_TextChanged(object sender, EventArgs e)
    {
    // code for searching in grid
    Grid.Rebind();
    }


    when i write in txtbox ...txtbox_textChanged event is not fired ..Please Help
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 07 Mar 2014 Link to this post

    Hi Mayank,

    During the keyup event the RadTextBox control is still not updated it's internal value. And when you do the postback, the old value will be submitted. I see that you have set AutoPostBack=true, so I could suggest you to call set_value() to force the applying of the new value and do the postback.

    Here is an example code:
    txtbox.Attributes.Add("onkeyup","function(this, event) { $find(this.id).set_value( this.value)};");


    Regards,
    Vasil
    Telerik

    DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mayank
    Mayank avatar
    5 posts
    Member since:
    Jan 2014

    Posted 10 Mar 2014 in reply to Vasil Link to this post

    Hey Thanks vasil for your reply .....now  it works ....but i m facing a new problem how to put this RedTextBox inside ajax update panel...
    thanks in advance :)
Back to Top