views:

141

answers:

3

I used asp.net server side control to display and modify data in database, the control is just like this one: http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/alleditablecolumns/defaultcs.aspx what I want to do is after I click the "edit" button it will display a "edit" ui, and I want everytime I modify the data in the text box, asp.net will automatically click the "update" button for me to update the data i entered.

I tried to call the event handler, but failed. There is a update command in asp.net, and how to programmatically call it ?

A: 

Probably you will have to use the onTextChanged event of your TextBox control.

Ravia
A: 

Try this. You can get the event refernce via this code

string postbackEvent = this.ClientScript.GetPostBackEventReference(this.button,"");

the postbackEvent will contains a __doPostback() function, which will invoke the button click in the server side. Assign this to some event, like onBlur of textbox.

this.txtSample.Attributes.Add("onBlur",postbackEvent);
Anuraj
Can I just directly execute the postbackEvent ?what function should I call ?
MemoryLeak
You will get the Post back even in the postbackEvent variable. And I am not sure it is recommended method or not, but try using Eval() method.
Anuraj
A: 

Set the autopostback attribute to "true"

<asp:TextBox AutoPostBack="True" ID="somethingID" OnTextChanged="CallSomeMethod" />

Look here : http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.autopostback.aspx

krishna