473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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.
Nov 19 '05 #1
3 2489
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.

Nov 19 '05 #2
Thanks, I'll have a look.

L.

"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:C2**********************************@microsof t.com...
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.

Nov 19 '05 #3
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" <ne**@creations-software.co.uk> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
Thanks, I'll have a look.

L.

"Phillip Williams" <Ph**************@webswapp.com> wrote in message
news:C2**********************************@microsof t.com...
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.


Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: UGH | last post by:
I am adding image buttons dynamically and I need to add event handler when the user clicks on one of those image buttons which will have different id for reports. Here is my code LnkImage =...
1
by: Luis Esteban Valencia Muñoz | last post by:
Have a dropdownlist created in my LoadMain() which is called from the Page_load: ************************PAGE LOAD********************8Private Sub Page_Load(ByVal sender As System.Object, ByVal e...
4
by: DJ | last post by:
Good morning, Still new at this so please bear with me. I am creating a table dynamically using webcontrols based on the output of a sproc from my database.The table represents test instances...
2
by: Just Me | last post by:
When a document is to be printed I call a method that contains an AddHandler statement. I just realized that if a second copy is to be printed the method is called and the AddHandler is executed...
10
by: Rick Palmer | last post by:
I have an app I'm working on that will allow a user to run one of 5 reports. The report names are in a combobox on my form. I have a sub defined for each report that has the exact same name as is...
5
by: eBob.com | last post by:
I've used AddHandler for a UNIQUE control added to a panel and it seemed to work. But now I want to add a bunch of controls to a panel and use only one event handler subroutine. And I am...
3
by: hartley_aaron | last post by:
Hi, I was trying to store the address of the my current handler for a particular event so as to simplify using AddHandler and RemoveHandler throughout my code. However, I cannot seem to get any...
2
by: TrtnJohn | last post by:
If you call AddHandler and hook events of one object to a method in a class will the event source object still be available for garbage collection if the original reference is set to Nothing? Or...
2
by: Joe | last post by:
Hello All: Can I wire server control events in the page's PreRender event and have them take effect? I am rendering LinkButtons in a Table on a webform and am using AddHandler to wire each...
5
by: Slim | last post by:
i have a simple page, with one button button1. when click it creates a new button button 2 and adds a event handler to it. but when button 2 is clicked nothing happens, why? Partial Class...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.