Re: help with events (i'm new to this)

From: Teemu Keiski (joteke_at_aspalliance.com)
Date: 06/25/04


Date: Fri, 25 Jun 2004 13:16:38 +0300

Hi,

user control instances would need to be loaded at the page_load (on postback
request relative to the UC itself) so that they'd be able to raise postback
events.

One way around is to use a flag value (in ViewState collection) to indicate
that control should be created (or how many controls should be created) on
postback so that they could be loaded at the page_load.

If you want to see a n example, go to:
http://www.microsoft.com/mspress/books/companion/6578.asp#Companion%20Content
(Code download for Microsoft® ASP.NET Coding Strategies with the Microsoft
ASP.NET Team )

See the code for chapter one and there 'DynamicTextBox.aspx', it gives you a
good example.

-- 
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke
"Colin Robinson" <ColinRobinson___@cix.co.uk> wrote in message
news:OLy%23aIjWEHA.3596@tk2msftngp13.phx.gbl...
> I can see there is an issue with web user control events on postback but
> dont fully understand how to implement a solution.
>
> I have a button on my aspx page, when clicked it adds instances of my web
> user control to a placeholder, it looks ok visually but events in the
> usercontrol dont fire.How should I instatiate my usercontrol instances so
> that events within them fire as expected?
>
> I am currently using the sysntax  on the clickevent of a button
>
> dim ocontrol as mycontrol = loadcontrol("~Mycontrol.asax")
> me.placeholder.controls.add(ocontrol)
>
> Cheers
>
>
>
>
>
>