asp.netupdatecommandserver-side-controls

How to automatically click "update" button in asp.net control?


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 ?


Solution

  • 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);