Newbie Question: One event triggers two event handlers

M

MattNC

Hi, I'd appreciate any help with this. I'm new to this so I'll need
things spelled out. I have a web form that creates an XML document when
it is submitted. The code behind has the event handler, everything
works fine. But I'm trying to also write a cookie on the OnClick event.
How do I add a second handler to one event? I've tried:

private void InitializeComponent(){
this.submitBtn.Click += new System.EventHandler(this.SubmitLead,
this.MakeCookie);
}

The first handler works great, but the second one does nothing. Here's
my code for the MakeCookie method:

public void MakeCookie(object sender, System.EventArgs e){
HttpCookie MyCookie = new HttpCookie("clientco");
MyCookie.Value = "submitted";
DateTime dt = DateTime.Now;
TimeSpan ts = new TimeSpan(100,30,0,0,0);
MyCookie.Expires = dt + ts;
Response.Cookies.Add(MyCookie);
}

Thanks!
 
G

Guest

this.submitBtn.Click += new System.EventHandler(this.SubmitLead);
this.submitBtn.Click += new System.EventHandler(this.MakeCookie);
 
M

MattNC

Thanks, I had tried that already and couldn't get it to work. Any idea
what I might be missing?
 

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

Top