User Control Strange Request

  • Thread starter Thread starter margelos
  • Start date Start date
M

margelos

I have a user control that contains a button with a btnSubmit_Click
code. I put the control in a page and works great. I want to have the
ability in some pages to add some code to the page in order to be
executed just before the btnSubmit_Click and then the rest code of the
button will be executed normally. Can this be done? With a delegate
maybe? If so can you help me?

Thanks
 
Try exposing the button's Click event as the control's public property and
subscribing to it as

myControl.Click += new EventHandler(this.My_Click);

void My_Click(Object sender, EventArgs e)
{
....
}

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
Xm sounds good, but how i can make event as property??

Can you provide some code?

Thanks again

Ï/Ç Eliyahu Goldin Ýãñáøå:
 
The only thing that did was at the page

protected void Page_Load(object sender, EventArgs e) {
deposit.PreButton += new
ShopDeposit.BeforeSubmit(deposit_PreButton); // User control
}

void deposit_PreButton(object sender, EventArgs e) {
// Your Code
}

Ï/Ç Tim Heuer Ýãñáøå:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top