Edit: For those who come here with the same problem, now I know that this is a Had a bad idea.
Hi, I have something like this:
bool preventEvents; Secure Zero Page_load (object sender, event e) {preventEvents = doSomeValidation (); } Secure Zero Button 1_Click (Object Sender, EventArgs E) {If (preventEvents) Return; // ...} Protected Zero Repeater 1_DataBound (Object Sender, EventArgs E) {If (preventEvents) Return; // ...}
The problem is that I have a lot of events on the page.
Is it possible that all further events are line without any "if" method?
Edit:
got some interesting answers (thanks to everyone) but what I do not see Maybe I should be more specific:
Some conditions have been given, it is possible to leave all events after page_load and jump on the rendering, without manually deleting / mapping each event It is possible
You can not "proceed" in the rendering because it contains Oi condition is not processes to allow for-Revestman
The only option is to hack handle events relevant controls.
Secure Zero Page_load (Object Sender, EventArgs E) {// Do not Do It !! In recent years, some poor souls who debug your code have to get their hair out, as long as they do not discover the profane magic here. Keep in mind that this is the 21st century and this person knows where you live. // // Seriously, just use the verification made in ASP.NET if (disable the "true" .Equals (Request.QueryString ["disable_events"], StringComparison.OrdinalIgnoreCase)) // disable * all * button controller foreach On the event handlers (var b. GetControlDescendants (). OfType & lt; button & gt; ()) {Var Event List = (EventHandler List) Typef (Control) .GetProperty ("Events", BindingFlag.Instance | BindingFlag NonPublic ) .GetValue (b, null); Typef (event handler list). Gatefield ("head", binding fengj.instance | bindingfags, nonPublic) .SetValue (Eventilist, blank); }}}
Utility Extension Method for Completion:
/// & lt; Summary & gt; /// Controls the control of a fourth-first traversal of the tree. Unlike /// search control, this method does not fall under the control which /// so far as EnsureChildControls are /// & lt; / Summary & gt; /// & lt; Returns & gt; Count of visited controls & Lt; / Returns & gt; Public stable IEnumerable & lt; Control & gt; GetControlDescendants (this control parent) {// EnsureChildControls execute does not apply (! Parent.HasControls ()) break the yield; Leading (Parents control children in control) {yield returns child; } In the foreach (guardian control child.) {Foreach (high descendant in child. GETControlDescendants ()) yield yields; }}}
Comments
Post a Comment