This is a migrated thread and some comments may be shown as answers.

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

2 Answers 241 Views
Input
This is a migrated thread and some comments may be shown as answers.
Mayank
Top achievements
Rank 1
Mayank asked on 07 Mar 2014, 10:40 AM
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 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 07 Mar 2014, 03:32 PM
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.

0
Mayank
Top achievements
Rank 1
answered on 10 Mar 2014, 07:39 AM
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 :)
Tags
Input
Asked by
Mayank
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Mayank
Top achievements
Rank 1
Share this question
or