Capture button click events in pageload

Source: Internet
Author: User
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
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.