Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / October 2005

Tip: Looking for answers? Try searching our database.

AddHandler VB.NET and ASP.NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Landley - 18 Oct 2005 23:26 GMT
Hi,

I have created a simple Web User Control.  It dynamically creates a table.
With a cell in the table, it creates a Button control set to run at the
server.  I then call AddHandler and handle the Click event from the button
and raise it as an event within my User Control.  This seems to be
happening, so much as it getting the RaiseEvent line, but it just does not
raise the event.  There are no errors, it just carries on executing.

Is there an issue with dynamically adding controls to a user control and
wrapping their events in a single event in a User Control using VB.NET in
ASP.NET?  If not, can someone post a sample on how to do so?

L.
Phillip Williams - 18 Oct 2005 23:40 GMT
For dynamically created controls consider carefully the page lifecycle.  

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/vie
wstate.asp


If you create controls after the initialization stage make sure that you
recreate them again during the Page_init or at least Page_load otherwise
their events would be lost.  In this simple demo
http://www.societopia.net/Samples/DynamicallyCreatedControls.aspx  I create
the controls later in the page but persist some indicators that allow me to
recreate them upon page_load and thereby preserve their event handling.  

Signature

HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com

> Hi,
>
[quoted text clipped - 10 lines]
>
> L.
Landley - 18 Oct 2005 23:48 GMT
Thanks, I'll have a look.

L.

> For dynamically created controls consider carefully the page lifecycle.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/vie
wstate.asp


> If you create controls after the initialization stage make sure that you
> recreate them again during the Page_init or at least Page_load otherwise
[quoted text clipped - 17 lines]
> >
> > L.
Landley - 19 Oct 2005 14:24 GMT
I fixed my issue.

The ID on the aspx pages was called something totally different to the one
declared in the aspx.vb file!  I know, I know!  Basic error!

Thanks anyway.

Landers.

> Thanks, I'll have a look.
>
> L.
>
> > For dynamically created controls consider carefully the page lifecycle.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/vie
wstate.asp


> > If you create controls after the initialization stage make sure that you
> > recreate them again during the Page_init or at least Page_load otherwise
[quoted text clipped - 23 lines]
> > >
> > > L.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.