Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Adding User Control

Reply
Thread Tools

Adding User Control

 
 
Slawek
Guest
Posts: n/a
 
      09-11-2003
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


 
Reply With Quote
 
 
 
 
John Saunders
Guest
Posts: n/a
 
      09-11-2003
"Slawek" <> wrote in message
news:...
> 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?
--
John Saunders
Internet Engineer



 
Reply With Quote
 
 
 
 
Slawek
Guest
Posts: n/a
 
      09-12-2003
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)


"John Saunders" <> wrote in message
news:...
> "Slawek" <> wrote in message
> news:...
> > 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?
> --
> John Saunders
> Internet Engineer
>
>
>



 
Reply With Quote
 
John Saunders
Guest
Posts: n/a
 
      09-12-2003
Interesting. Perhaps you could remove the event handlers before removing the
control?
--
John Saunders
Internet Engineer



 
Reply With Quote
 
Slawek
Guest
Posts: n/a
 
      09-12-2003
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

"John Saunders" <> wrote in message
news:...
> Interesting. Perhaps you could remove the event handlers before removing

the
> control?
> --
> John Saunders
> Internet Engineer
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
User Control to Control Other User Control Jonathan Wood ASP .Net 4 02-02-2010 03:41 PM
Adding a web user control to a web control library rsam2011@yahoo.com ASP .Net 1 10-11-2006 03:22 AM
persisting changes to a control outside a user control from the user control? Mad Scientist Jr ASP .Net 0 03-22-2006 08:02 AM
Dynamically Adding User Control with Child User Control Travis Pruitt ASP .Net Building Controls 0 01-13-2005 08:49 PM
Manipulating a User Control from another User Control Tom Rowton ASP .Net 2 08-01-2003 08:18 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57