AddHandler VB.NET and ASP.NET  
Author Message
Landley





PostPosted: 2005-10-19 6:26:40 Top

dotnet-framework-aspnet, AddHandler VB.NET and ASP.NET 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.


 
UGhpbGxpcCBXaWxsaWFtcw





PostPosted: 2005-10-19 6:40:00 Top

dotnet-framework-aspnet >> AddHandler VB.NET and ASP.NET For dynamically created controls consider carefully the page lifecycle.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/viewstate.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.

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


"Landley" wrote:

> 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.
>
>
>
 
Landley





PostPosted: 2005-10-19 6:48:00 Top

dotnet-framework-aspnet >> AddHandler VB.NET and ASP.NET Thanks, I'll have a look.

L.

"Phillip Williams" <email***@***.com> wrote in message
news:email***@***.com...
> For dynamically created controls consider carefully the page lifecycle.
>
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/viewstate.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.
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "Landley" wrote:
>
> > 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.
> >
> >
> >


 
 
Landley





PostPosted: 2005-10-19 21:24:00 Top

dotnet-framework-aspnet >> AddHandler VB.NET and ASP.NET 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.


"Landley" <email***@***.com> wrote in message
news:%email***@***.com...
> Thanks, I'll have a look.
>
> L.
>
> "Phillip Williams" <email***@***.com> wrote in message
> news:email***@***.com...
> > For dynamically created controls consider carefully the page lifecycle.
> >
> >
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/viewstate.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.
> >
> > --
> > HTH,
> > Phillip Williams
> > http://www.societopia.net
> > http://www.webswapp.com
> >
> >
> > "Landley" wrote:
> >
> > > 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.
> > >
> > >
> > >
>
>