Adding User Control

S

Slawek

Hi everyone,
I have a problem that I can't resolve. I have created a user control which
is included in asp.net page (<@register...etc). All I need is to move this
control from one place on the page to another(in Page_Load method). For
example my control belongs to one cell (<td>) tag and I have to move it to
another cell(<td>). In c# code I use <new tag>.Controls.Add(mycontrol) and
it works perfect, accept that after moving control, all events for my
control are fired twice(for example Load in my control and even pressing
button in it). It looks like after adding control to new tag there is two
instances of my control on the page. Because of this my application works
improperly. I don't know how to fix it. Any suggestions ??

Regards
Slawek
 
J

John Saunders

Slawek said:
Hi everyone,
I have a problem that I can't resolve. I have created a user control which
is included in asp.net page (<@register...etc). All I need is to move this
control from one place on the page to another(in Page_Load method). For
example my control belongs to one cell (<td>) tag and I have to move it to
another cell(<td>). In c# code I use <new tag>.Controls.Add(mycontrol) and
it works perfect, accept that after moving control, all events for my
control are fired twice(for example Load in my control and even pressing
button in it). It looks like after adding control to new tag there is two
instances of my control on the page. Because of this my application works
improperly. I don't know how to fix it. Any suggestions ??

How about if you remove the control from the first cell before adding it to
the second cell?
 
S

Slawek

Add Command removes it from first control collection befor adding to the
second one, but even if I do it myself it doesn't work. (The control is
removed - id doesn't appear on the page twice, but it receives all events
two times)
 
J

John Saunders

Interesting. Perhaps you could remove the event handlers before removing the
control?
 
S

Slawek

But how can I do it?? All events for my control are raised for two times.
For example if there is a button in that control and I've button_click()
method in code - it'll by called twice :(

Regards
Slawek
 

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

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top