This article briefly introduces how to use C # WinForm in asp.net to determine whether the form control has modified the implementation code. If you need it, refer to modify.
The custom code is as follows:
| The Code is as follows: |
Copy code |
Interface IModify { Bool IsModified {get ;} } Class TextBoxEx: TextBox, IModify { Private bool isModified = false; Public bool IsModified { Get {return isModified ;} } Protected override void OnTextChanged (EventArgs e) { This. isModified = true; Base. OnTextChanged (e ); } } |
2. Usage
| The Code is as follows: |
Copy code |
Private void button#click (object sender, EventArgs e) { Var B = IsModify (this ); Text = B. ToString (); } Private bool IsModify (Control ctrl) { Foreach (Control control in ctrl. Controls) { If (control. Controls. Count> 0) Return IsModify (control ); If (control is IModify) { If (IModify) control). IsModified) Return true; } } |