help with events (i'm new to this)

C

Colin Robinson

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
 
T

Teemu Keiski

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 Content
(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.
 
C

Colin Robinson

thanks,

I set them up visible false in load thenchanged visibility as required
 

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,023
Latest member
websitedesig25

Latest Threads

Top