Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > AddHandler VB.NET and ASP.NET

Reply
Thread Tools

AddHandler VB.NET and ASP.NET

 
 
Landley
Guest
Posts: n/a
 
      10-18-2005
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.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=
Guest
Posts: n/a
 
      10-18-2005
For dynamically created controls consider carefully the page lifecycle.

http://msdn.microsoft.com/library/de.../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/Dy...dControls.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.
>
>
>

 
Reply With Quote
 
 
 
 
Landley
Guest
Posts: n/a
 
      10-18-2005
Thanks, I'll have a look.

L.

"Phillip Williams" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> For dynamically created controls consider carefully the page lifecycle.
>
>

http://msdn.microsoft.com/library/de.../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/Dy...dControls.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.
> >
> >
> >



 
Reply With Quote
 
Landley
Guest
Posts: n/a
 
      10-19-2005
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Thanks, I'll have a look.
>
> L.
>
> "Phillip Williams" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > For dynamically created controls consider carefully the page lifecycle.
> >
> >

>

http://msdn.microsoft.com/library/de.../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/Dy...dControls.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.
> > >
> > >
> > >

>
>



 
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
AddHandler and dynamically generated controls Greg ASP .Net Web Controls 2 02-12-2008 03:16 PM
Convert ADDHandler and AddressOf to C# =?Utf-8?B?Q2FybG8zMDMw?= ASP .Net 6 05-09-2006 04:38 AM
Event AddHandler Kay ASP .Net 2 02-03-2004 07:02 PM
Re: Help w/AddHandler (Not Firing Off) Natty Gur ASP .Net 1 08-11-2003 03:06 PM
Help w/AddHandler (Not Firing Off) Jeffrey A. Voigt ASP .Net 3 08-11-2003 04:53 AM



Advertisments