A user needs to record the log for each button, which is troublesome ~
Think of two solutions
1. process the pageload event, capture the button click event, and record the log.
2. Customize a button control and process it in the base class of the button.
At present, I found the method for the first issue, but I feel that if there are many page elements, it may be slow and I have not tested it yet.
If imagebutton is obtained, the buttonid obtained from page. Request. Form carries the coordinates of imagebuttond,
Buttonid. X and buttonid. Y. Therefore, in page. findcontrol, remove. X or. Y of buttonid. Otherwise, the imagebutton cannot be found in findcontrol.
Protected Void Pagebase_load ( Object Sender, eventargs E)
{
Foreach ( String Buttonid In This . Page. Request. Form)
{
// The request's button ID captured during page load.
Control pagecontrol = This . Page. findcontrol (buttonid );
If (Pagecontrol Is Button)
{
//This. Page. response. Write (pagecontrol. ID + ";" + pagecontrol. clientid + "; <br/> ");
}
Else If (Pagecontrol Is Imagebutton)
{
}
}
}
The second method is theoretically implemented in the following way, but the test has not been conducted.
Using System;
Using System. Data;
Using System. configuration;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. webcontrols;
Using System. Web. UI. webcontrols. webparts;
Using System. Web. UI. htmlcontrols;
/**/ /// <Summary>
///Summary Description for logbutton
/// </Summary>
Public Class Logbutton: button
{
Public Logbutton ()
{
//
//Todo: Add constructor logic here
//
}
Protected Override Void Onclick (eventargs E)
{
Base. Onclick (E );
//Save log
}
}