0

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 ?

MemoryLeak
  • 7,322
  • 23
  • 90
  • 133

3 Answers3

0

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

Ravi Vanapalli
  • 9,805
  • 3
  • 33
  • 43
0

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
  • 18,859
  • 7
  • 53
  • 79
  • Can I just directly execute the postbackEvent ?what function should I call ? – MemoryLeak Jan 11 '10 at 07:19
  • 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 Jan 11 '10 at 08:08
0

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
  • 1,366
  • 2
  • 15
  • 23