JavaScript operations in ASP.NET

xiaoxiao2021-03-06  51

1. Add a confirmation for the Button Control to add a client to the server control to the server control, you need to use the Attributes property. Attributes property is an attribute that all server controls have, which is used to add some custom tags for the final generated HTML. Suppose there is a save button BTnsave on the Web Form, I hope that the user is prompted to be saved when the user clicks this button (for example, once saved, it should be added to the Page_Load Event: btnsave.attributes.add (" OnClick "," JavaScript: Return Confirm ('Are You Sure?'); ") It is necessary to pay attention to 'return', which is inevitably, otherwise the data will remain saved even if the user is canceled. 2. Adding JavaScript events in DataGrid, the child control in the DataGrid is no way to access directly. To implement the above effect, we need to use the DataGrid onItemDatabase. OnItemDatabase happens after the DataGrid's data is bound to the DataGrid (ie, one line is excited). First add the onItemDatabase attribute in the DataGrid declaration, as follows:

转载请注明原文地址:https://www.9cbs.com/read-87534.html

New Post(0)