Interaction with life cycle of page
So, recording in the table is edited, it are necessary to save her . The first, that occurs is entirely AJAX the decision when the data are going to from edited line DataGrid, are sent on the server, and in case of success client PostBack function pererisovyvaet a line of the table already only for viewing. However, if the first part of this idea does not cause any difficulties copying of the table puts some questions. First, for the general{common} case it is necessary to find a way to receive from the server performance ItemTemplate of each element of management in an edited line i.e. as columns in browse mode are displayed. Further to the data received from the server together with performance to find corresponding places on page where all this to insert. And to make an insert.
As an alternative variant, it is possible to try to collect on the server all the line long tables, to find on the client its{her} place on page and to insert. Even if to find a way all this to make be relative a small amount of a code, there is a following question. What to do{make} with a status of page, in fact ViewState pages stores{keeps} other data and at the first PostBack (for example, in case of kill or sortings), the table will still consider, that the certain line is in a status of editing, and values of elements "will rise" from ViewState old. "Dostuchat`sja" up to objective model it is not possible, as by an asynchronous call, the objective model of page is not initialized, so AJAX the method knows nothing about existing in life cycle of page objects.
Theoretically, it is possible to act{arrive} as it does{makes} ASP .NET 2, namely to initialize almost all steps of life cycle, except for Render. Further to change objects of page on new and it guarantees, that at the following reference{manipulation} to page we shall receive expected positive result. At such decision there are two significant minuses: for enough simple logic action, otrisovki lines of the table, a lot of code is necessary to write, and thus loading on the server remains at the same level, as at simple PostBack. As a matter of fact, unique plus becomes that the user does not see as pererisovyvaetsja all page.
Meanwhile, in my opinion the correct decision will be a call of function __ doPostBack in client CallBack functions.
So, by pressing the client of button Update, the following function is caused:
function updateEq (controlID) {
var _eqInfo = AdminEditor. EqEditor. GetEqInfoMetaData () .value;
var lastind = controlID.lastIndexOf (' _ ');
var prefix = controlID.substring (0, lastind + 1);
_eqInfo. DepartmentID = document.getElementById (prefix + "ddlstDepartment") .value;
_eqInfo. DeviceModelID = document.getElementById (prefix + "ddlstDevicemodelID") .value;
_eqInfo. OfficeID = document.getElementById (prefix + "ddlstOffice") .value;
_eqInfo. RoomID = document.getElementById (prefix + "ddlstRoom") .value;
_eqInfo. InvNumber = document.getElementById (prefix + "txtInvNumber") .value;
_eqInfo. Comment = document.getElementById (prefix + "txtComment") .value;
tmp = document.getElementById (prefix + "txtComissDate") .value;
if (tmp.length> 0) {
arr = tmp.split(".;
_eqInfo. ComissDate = new Date (arr [2], arr [1]-1, arr [0]);
}
_eqInfo. Discarded = document.getElementById (prefix + "chkDiscardedE") .checked;
var deviceID = document.getElementById (prefix + "deviceID") .value;
AdminEditor. EqEditor. UpdateEq (deviceID, _eqInfo, updateEq_callback);
}
In this code, the presence{finding} of elements of management in line on ID buttons is more universal, than in the previous examples. There is a prefix collected ASP.NET depending on position of an element of management in those or other panels, user "kontrolakh" and at last, from number{room} of an edited line in the table. For example, the falling list of a choice of office in an edited line can look so: grdEquipment __ ctl6_ddlstOffice, that means that he belongs to the table grdEquipment, a line _ctl6. But, in general the prefix can be and is longer.
In the first line of the above-stated function from the server we receive structure for the further filling with its{her} data and sendings on the server. I.e. actually, we receive the metadata on the basis of which we form object and it is sent it on the server for preservation. After a call of a server method, management is passed client function:
function updateEq_callback (res) {
if (res.value.length> 0) alert (res.value); else {
__ doPostBack ("", LoadData ");
}
}
At absence of mistakes, she realizes PostBack pages. The only thing that is remarkable in this code, this that that as parameter eventArgument I send a flag "LoadData" which I interpret in life cycle of page as reading of the actual information from a database. Otherwise, the table would be filled by the data from old ViewState or from out-of-date session, that at updating it is incorrect., perhaps and all.

|