tags:

views:

121

answers:

1

How do i use overload in C#

I have a sample codes that goes like this

Namespace Test
Partial Class TestAccess
    Inherits BaseForm

    Dim db As New database
    Dim share As New ShareMethod

    Protected Overloads Overrides Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        MyBase.Page_Load(sender, e)

I tried using the converter, but keep getting error.

And my overload doesnt have any function, so do i still use .....+....

****UPDATED

Here is my codes for the program which i want to inherit

namespace CRRBaseForm

{

public partial class TAView : BaseForm
{
    protected override void Page_Load(object sender, EventArgs e)
    {
        if (Page.IsPostBack == false)
        {
            binddropdownlists();
        }
    }

currently nothing happens. but when i did this; it tells me that i need to overload:

    namespace CRRBaseForm
{

    public partial class TAView : BaseForm
    {
        protected override void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                Page_Load(); //call from BaseForm
                binddropdownlists();
            }
        }

my baseform is as follow:

namespace CRRBaseForm
{

public partial class BaseForm : System.Web.UI.Page
{
    protected virtual void Page_Load(object sender, EventArgs e)
    {
        //Check if the Session Login id null
        if (Session["UserID"] == null)
        {...
...
...
+1  A: 

In C#, it is like so:

protected override void Load (object sender, EventArgs ea)
{
}

Assuming a 'Load' virtual or abstract method in the parent class.

-- Edit

You've updated your question, and you have this:

Page_Load(); //call from BaseForm

That actually needs to be:

base.Page_Load(); //call from BaseForm

Otherwise it will just call itself recursively.

Noon Silk
You are missing a return type in your method signature.
Darin Dimitrov
@darin: Fixed.
Jon Skeet
i tried but it didnt work.
Nana
I've updated the post slightly, as you have a problem in the posted code; but the overriding should work. Please show the actual compilation error you are getting.
Noon Silk
when i've done that, i have this error which is the same error.Dont quite understand the error thoughNo overload for method 'Page_Load' takes '0' arguments
Nana
I don't understand how the code you have shown is producing that error.
Noon Silk
hahas. hmmmm. is there any other place i have to check?
Nana
I know why. Because there is no parameter. So, i insert this: base.Page_Load(sender,e);But, still never inherit anything from the baseform. :((((
Nana