Is there any way to do this?

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

Example: I have a ASP.NET project called TestApp written in c#. It has
WebForm1.aspx/WebForm1.aspx.cs. There is a button click event for
Button 1. It updates a label on the form. The code for the
Button1_Click is:

private void Button1_Click(object sender, System.EventArgs e)
{
this.Label1.Text = "Button was clicked";
}


What I would like to be able to do is in a class file, be able to do
something like:

namespace TestApp
{
class WebForm1
{
private override Button1_Click(object sender, System.EventArgs e)
{
this.Label1.Text = "My class, not the form, updated this label.";
}
}
}


The only way I can explain it is hooking into a function and overriding
it to do what I want. Does this make any sense? Can this be done?

Thanks in advance.
Paul
 
I'm curious , what's your intension behind it. What different it makes
wheather you overide even handler or not ?
 
Back
Top