<p>In my code behind I wire up my events like so:</p>

<pre><code>protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    btnUpdateUser.Click += btnUpateUserClick;
}
</code></pre>

<p>I've done it this way because that's what I've seen in examples. </p>

<ul>
<li>Does the base.OnInit() method need to be called? </li>
<li>Will it be implicitly be called? </li>
<li>Is it better to call it at the beginning of the method or at the end? </li>
<li>What would be an example where confusion over the base method can get you in trouble?    </li>
</ul>

[{'answer_id': 19296, 'author': 'David Wengier', 'author_id': 489, 'author_profile': 'https://Stackoverflow.com/users/489', 'pm_score': 0, 'selected': False, 'text': '<p>In this case, if you don\'t call the base OnInit, then the Init even will not fire.</p>\n\n<p>In general, it is best practice to ALWAYS call the base method, unless you specifically know that you do not want the base behaviour to occur.</p>\n\n<p>Whether its called at the start or the end depends on how you want things to work. In a case like this, where you are using an override instead of hooking up an event handler, calling it at the start of the method makes more sense. That way, your code will run after any handlers, which makes it more emulate a "normal" event handler.</p>\n'}, {'answer_id': 19299, 'author': 'Matt Hamilton', 'author_id': 615, 'author_profile': 'https://Stackoverflow.com/users/615', 'pm_score': 0, 'selected': False, 'text': "<p>Although the official framework design guidelines recommend otherwise, most class designers will actually make the OnXxx() method responsible for firing the actual event, like this:</p>\n\n<pre><code>protected virtual void OnClick(EventArgs e)\n{\n    if (Click != null) Click(this, e);\n}\n</code></pre>\n\n<p>... so if you inherit from the class and don't call base.OnClick(e), the Click event will never fire.</p>\n\n<p>So yes, even though this <em>shouldn't</em> be the case according to the official design guidelines, I think it's worth calling base.OnInit(e) just to be sure.</p>\n"}, {'answer_id': 19302, 'author': 'David Wengier', 'author_id': 489, 'author_profile': 'https://Stackoverflow.com/users/489', 'pm_score': 0, 'selected': False, 'text': "<blockquote>\n  <p>official framework design guidelines recommend otherwise</p>\n</blockquote>\n\n<p>They do? I'm curious, i've always thought the opposite, and reading Framework Design Guidelines and running FxCop has only cemented my view. I was under the impression that events should always be fired from virtual OnXxx() methods, that take an EventArgs parameter</p>\n"}, {'answer_id': 19306, 'author': 'Matt Hamilton', 'author_id': 615, 'author_profile': 'https://Stackoverflow.com/users/615', 'pm_score': 3, 'selected': True, 'text': '<p>I should clarify:</p>\n\n<p>The guidelines recommend that firing an event should involve calling a virtual "On<em>EventName</em>" method, but they also say that if a derived class overrides that method and forgets to call the base method, the event should still fire.</p>\n\n<p>See the "Important Note" about halfway down <a href="http://msdn.microsoft.com/en-us/library/ms229011.aspx" rel="nofollow noreferrer">this page</a>:</p>\n\n<blockquote>\n  <p>Derived classes that override the protected virtual method are not required to call the base class implementation. The base class must continue to work correctly even if its implementation is not called.</p>\n</blockquote>\n'}, {'answer_id': 19313, 'author': 'David Wengier', 'author_id': 489, 'author_profile': 'https://Stackoverflow.com/users/489', 'pm_score': 0, 'selected': False, 'text': "<p>You probably are better off doing it that way, then this debate goes away. The article is interesting though, especially considering that the .NET Framework doesn't honour this guideline.</p>\n"}, {'answer_id': 19320, 'author': 'Matt Hamilton', 'author_id': 615, 'author_profile': 'https://Stackoverflow.com/users/615', 'pm_score': 0, 'selected': False, 'text': "<p>@Ch00k and @Scott I dunno - I like the On<em>EventName</em> pattern myself. And yeah, I'm one of the people who are guilty of firing the event from that method.</p>\n\n<p>I think overriding the On* method and calling the base one is the way to go. Handling your own events seems wrong somehow.</p>\n"}]
['https://Stackoverflow.com/questions/19294', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1894/']