santosh singh
santosh singh

Reputation: 28652

How to override base method in asp.net?

I want to create custom Textbox control in asp.net.But i have one doubt when i override the base method i got predefined syntax something like this

 base.OnRender(writer);

Now my question is that from where I should start witting the code means before Base.OnRender or after base.OnRender.

Upvotes: 0

Views: 582

Answers (3)

Oded
Oded

Reputation: 499112

If you don't want the base class behavior to occur at all, you should delete the line.

Whether you should write your code before, after or in between depends on the semantics of the call and method (that is, what the base method does and what you want to do in the overriden method).

For example, if you want to inject HTML before the HTML of the base class, you will add your code before. If after, you would write your code after. If you want to wrap the HTML in yours, you would write code before and after.

Upvotes: 1

TalentTuner
TalentTuner

Reputation: 17556

normally , after base.OnRender.

Base methods should only be included if you want to inherit your base method behaviour and if it the case than you should start your overridden code after calling to the base method.

But this is not necessary but most logical and desriable.

Upvotes: 0

Dienekes
Dienekes

Reputation: 1548

The first line in your custom control's OnRender method would be base.OnRender(writer);.

Is this what you were looking for?

Upvotes: 0

Related Questions