wrong event source

  • Thread starter Thread starter Frank Schumacher
  • Start date Start date
F

Frank Schumacher

Hi NG,

I encountered another problem, which I don't really understand. Maybe
someone of you can give me a clue.

I have a WebForm with multiple UserControls of the same type on it. Each
uc is distinguished by a GUID, which I store in a Label.Text.
There is a button on each uc, which will fire an event, that is catched
by the WebForm. The code for raising the event looks like this:

private void ImageButtonClose_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
if (eventClose != null)
{
eventClose(this, this.LabelGUID.Text);
}
}

the problem is, that each second time, this function is called, the
value of this.LabelGuiD.Text is not from the uc where the Button is
pressed, but from the *next* uc in line.

I have absolutely no idea why this happens.

Thanks in advance,
Frank
 
Hi NG,

I have done some further research on my problem and now have an idea,
what have caused it, but not how to solve this.
It seems, that the values of the dynamically added ucs are added to the
viewstate of the site. When I unload the first uc in line, it seems,
that the *viewstate* of the uc is still present.
Then, when I click the new first uc, the website recognizes it as a
click on the *second* uc, for it has still the state of the previously
deletetd uc.
At the next roundtrip, it tells the server, that there is an event on
the *second* uc in line, therefor not adressing the first uc, which had
the event.

Well, this sounds confusing and actualy, I am confused. Hope some of you
have an idea.

Ciao,
Frank
 

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