Php simulates the asp. netwebFrom button to submit an event instance, asp. netwebfrom. Php simulates asp. the netwebFrom button submits event instances, asp. netwebfrom because the company needs php project development, php is just getting started. during The write button submission process, php simulates the asp.net webFrom button submission event instance in asp.net, asp. netwebfrom
As the company needs php project development, php is just getting started. in the process of writing button submission, the button events in asp.net are better. Let's take a look at the following code,
<? Require_once '../inc/EventHelper. php'; function Page_Load () {echo' will run at any time
'; If (! Page: IsPostBack () {echo 'load product category
'; If ($ _ GET ['cmd'] = 'edit') {echo' modifies and loads the product information to be modified.
';}} Function bAdd_Click () {// Comm: CheckQX ('product management_add'); echo "bAdd_Click
";} Function bEdit_Click () {// Comm: CheckQX ('product management_modify'); echo 'proid = '. $ _ GET ['proid'].'
'; Echo "bEdit_Click
";} Function sdfsdfdsf_Click () {echo" e44444444444444444444
";}?>
The above code, such as Page_Load, Page. IsPostback, and bAdd_Click, is familiar with asp.net development.
The above code runs the bAdd_Click function when you click the Add button (function seems to be the function). Similarly, click modify to automatically run the bEdit_Click event. There is no need for too many parameter changes or too many files. if the page features are not very complex, you can use this mode for rapid development.
Let's take a look at the code of the EventHelper. php file:
<? Class Page {// whether to send data back. 1: public static function IsPostBack () {global $ SYSRunEventName; return! Empty ($ SYSRunEventName);} // load and execute the event function EventLoad () {global $ SYSRunEventName; $ arrEvent = get_defined_functions (); $ arrEventUser = $ arrEvent ['user']; $ arr = array_keys ($ _ POST); foreach ($ arr as $ row) {$ name = strtolower ($ row); foreach ($ arrEventUser as $ row1) {$ name1 = str_ireplace ('_ Click', '', $ row1); if ($ name = $ name1) {$ SYSRunEventName = $ row1; break ;}} if (! Empty ($ SYSRunEventName) {break ;}} if (function_exists ('page _ load') Page_Load (); $ SYSRunEventRunName = strtolower ($ SYSRunEventName); if (Page :: isPostBack () {$ SYSRunEventName () ;}} class Comm {public static function GetParam ($ params = array (), $ cmd = 'addoverride ') {$ allParam = array (); if ($ cmd = 'addoverride') {$ arrKeys = array_keys ($ params); foreach ($ arrKeys as $ row) {if (! In_array ($ row, array_keys ($ allParam) $ allParam [$ row] = $ params [$ row] ;}} else if ($ cmd = 'Del ') {foreach ($ params as $ row) {unset ($ _ GET [$ row]) ;}}$ arrKeys = array_keys ($ _ GET ); foreach ($ arrKeys as $ row) {if (! In_array ($ row, array_keys ($ allParam) $ allParam [$ row] =_ _ GET [$ row] ;}$ p = ''; $ arrKeys = array_keys ($ allParam); foreach ($ arrKeys as $ row) {$ p. = $ row. '= '. $ allParam [$ row]. '&';} return rtrim ($ p, '&') ;}} Page: EventLoad ();?>
You can test the above functions. I have run php5.4 successfully, but I have not considered much about the security. I have read some articles about php and may execute php code on the client, because php has many practical features.
For Comm: GetParam, it is often necessary to obtain get parameters or modify parameters. for example, if all url parameters need to be retained during paging, only paging parameters (such as page = 5) are modified ), so I wrote some code on my own.
It mainly utilizes the following features of php:
Function_exists
Get_defined_functions
And uses common form submission principles to implement functions.
Due to the rush of time, it is too late to describe the specific principles. please forgive me. you can understand the code.
For the aspnet verification control instance, what do I want to know more about is the event code of the form submission button?
How to trigger the text of the verification control? If verification fails, an error message is displayed. various internal verification methods, such as regular expressions, should be used.
How can I call the click event of another button in a button click event in ASPnet,
Method 1: specify the event directly
Method 2: Add in the background
Protected void Page_Load (object sender, EventArgs e)
{
Button btn;
Btn = new Button ();
Btn. ID = "btn1 ";
Btn. Text = "button 1 ";
This. form1.Controls. Add (btn );
Btn. Click + = new EventHandler (btn1_Click );
Btn = new Button ();
Btn. ID = "btn2 ";
Btn. Text = "button 2 ";
This. form1.Controls. Add (btn );
Btn. Click + = new EventHandler (btn1_Click );
}
Protected void btn1_Click (object sender, EventArgs e)
{
Page. ClientScript. RegisterStartupScript (Page. GetType (),"","