473,473 Members | 2,292 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

general question concerning dynamically created buttons

djc
On the page_load event I am querying a database and binding data to some
text boxes, list boxes, and a repeater control. When the page loads it uses
the value of one of the database fields (status) to determine what options
should be available for this particular item (which is an issue... small
issue tracking system). Each of these options is an action that may be
performed on the issue and I am dynamically creating LinkButtons for each
available action. So, based on current status, I add LinkButton controls to
a panel. Each of these LinkButton controls has the same addHandler sub
routine which will perform the action based on the commandName. Thats the
basic setup I'm trying to acheive. I am in the middle of doing this and
realized a potential problem:

1) I have added the LinkButtons to the panel with no problem BUT I noticed
when clicking on one ALL of them disappear. I have not written the sub
routine for the addHandler for these linkButtons but the fact that they
disappeared upon clicking them raised some concerns. What gives? I mean, I
am kind of not suprised since these were created dynamically but I guess I
thought that viewstate would persist them through the postback. no? Maybe I
need to explicitly set them to persist through the postback?

2) If the LinkButtons disappear on postback will their command event fire?
Plus, I can't have them disappear... can I prevent that or do I have to
somehow add them again?

3) Do linkButtons always do a postback?

4) I guess this is probably a dumb question to those not new to asp.net but
here goes:
First an example of what I need to acheive. One of the link buttons will
enable a field to be updated. For example it will say "Update ETA" and upon
clicking it a textbox that currently contains the current ETA field data
will change its border, background color, and readOnly property to show that
you may now edit the data. And an update button will also be added below to
actually perform the update in the database. Thats the example. So heres the
dumb question: Is a postback required for that to happen? I am first
clicking on a button control (that was dynamically created on page load)
that needs to change the properties of another control and dynamically add
another button control. Then that button control performs the db update.

sorry for such a long winded post. I will be working on this again tomorrow
and just wanted to empty my questions out here and sleep on it.

any input is appreciated.
thanks.
Nov 18 '05 #1
2 1931
If you are creating the controls dynamically, you are responsible for
recreating them after the postback.

Denis Bauer has a free Placeholder control (with source code) that handles
the chore for you:

http://www.denisbauer.com/ASPNETCont...aceholder.aspx

Ken
Another
"djc" <dc*********@megapathdsl.net> wrote in message
news:O3**************@TK2MSFTNGP12.phx.gbl...
On the page_load event I am querying a database and binding data to some
text boxes, list boxes, and a repeater control. When the page loads it
uses
the value of one of the database fields (status) to determine what options
should be available for this particular item (which is an issue... small
issue tracking system). Each of these options is an action that may be
performed on the issue and I am dynamically creating LinkButtons for each
available action. So, based on current status, I add LinkButton controls
to
a panel. Each of these LinkButton controls has the same addHandler sub
routine which will perform the action based on the commandName. Thats the
basic setup I'm trying to acheive. I am in the middle of doing this and
realized a potential problem:

1) I have added the LinkButtons to the panel with no problem BUT I noticed
when clicking on one ALL of them disappear. I have not written the sub
routine for the addHandler for these linkButtons but the fact that they
disappeared upon clicking them raised some concerns. What gives? I mean, I
am kind of not suprised since these were created dynamically but I guess I
thought that viewstate would persist them through the postback. no? Maybe
I
need to explicitly set them to persist through the postback?

2) If the LinkButtons disappear on postback will their command event fire?
Plus, I can't have them disappear... can I prevent that or do I have to
somehow add them again?

3) Do linkButtons always do a postback?

4) I guess this is probably a dumb question to those not new to asp.net
but
here goes:
First an example of what I need to acheive. One of the link buttons will
enable a field to be updated. For example it will say "Update ETA" and
upon
clicking it a textbox that currently contains the current ETA field data
will change its border, background color, and readOnly property to show
that
you may now edit the data. And an update button will also be added below
to
actually perform the update in the database. Thats the example. So heres
the
dumb question: Is a postback required for that to happen? I am first
clicking on a button control (that was dynamically created on page load)
that needs to change the properties of another control and dynamically add
another button control. Then that button control performs the db update.

sorry for such a long winded post. I will be working on this again
tomorrow
and just wanted to empty my questions out here and sleep on it.

any input is appreciated.
thanks.


Nov 18 '05 #2
djc
thanks for the input. I'll check out the link.

"Ken Cox [Microsoft MVP]" <BA************@sympatico.ca> wrote in message
news:uF**************@TK2MSFTNGP10.phx.gbl...
If you are creating the controls dynamically, you are responsible for
recreating them after the postback.

Denis Bauer has a free Placeholder control (with source code) that handles
the chore for you:

http://www.denisbauer.com/ASPNETCont...aceholder.aspx

Ken
Another
"djc" <dc*********@megapathdsl.net> wrote in message
news:O3**************@TK2MSFTNGP12.phx.gbl...
On the page_load event I am querying a database and binding data to some
text boxes, list boxes, and a repeater control. When the page loads it
uses
the value of one of the database fields (status) to determine what options should be available for this particular item (which is an issue... small
issue tracking system). Each of these options is an action that may be
performed on the issue and I am dynamically creating LinkButtons for each available action. So, based on current status, I add LinkButton controls
to
a panel. Each of these LinkButton controls has the same addHandler sub
routine which will perform the action based on the commandName. Thats the basic setup I'm trying to acheive. I am in the middle of doing this and
realized a potential problem:

1) I have added the LinkButtons to the panel with no problem BUT I noticed when clicking on one ALL of them disappear. I have not written the sub
routine for the addHandler for these linkButtons but the fact that they
disappeared upon clicking them raised some concerns. What gives? I mean, I am kind of not suprised since these were created dynamically but I guess I thought that viewstate would persist them through the postback. no? Maybe I
need to explicitly set them to persist through the postback?

2) If the LinkButtons disappear on postback will their command event fire? Plus, I can't have them disappear... can I prevent that or do I have to
somehow add them again?

3) Do linkButtons always do a postback?

4) I guess this is probably a dumb question to those not new to asp.net
but
here goes:
First an example of what I need to acheive. One of the link buttons will
enable a field to be updated. For example it will say "Update ETA" and
upon
clicking it a textbox that currently contains the current ETA field data
will change its border, background color, and readOnly property to show
that
you may now edit the data. And an update button will also be added below
to
actually perform the update in the database. Thats the example. So heres
the
dumb question: Is a postback required for that to happen? I am first
clicking on a button control (that was dynamically created on page load)
that needs to change the properties of another control and dynamically add another button control. Then that button control performs the db update.

sorry for such a long winded post. I will be working on this again
tomorrow
and just wanted to empty my questions out here and sleep on it.

any input is appreciated.
thanks.

Nov 18 '05 #3

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

Similar topics

0
by: RussC | last post by:
My C# app has a toolbar with 12 or so buttons on it, all created via the designer. In some circumstances we need to add one or two buttons to it dynamically. I have code that does this and it...
1
by: Gopal Krish | last post by:
I'm have coded a simple menu (using link buttons as menu items) in a user control to be reused across many ASPX pages. In the page_load method I dynamically create the link buttons as follows ...
1
by: AndrewMBaldwin | last post by:
Ok, this is going to be a long post, so I apologize in advance, but if it was an easy question I would have probably found an answer somewhere out here by now... The short story of this is that...
3
by: Mark | last post by:
Assume you want to dynamically add one to many link button controls to a web page dynamically at run time. Each link button needs to post back and execute code. As the link buttons are created at...
2
by: =?Utf-8?B?TWlrZSBSYW5k?= | last post by:
I have created a method that dynamically creates a single button control (as a proof-of-concept, I would like to be able to create multiple buttons). I set properties on this control including an...
5
by: Amoril | last post by:
I've read quite a few different message on various boards and for some reason I'm still having trouble wrapping my head around this viewstate maintenance and trying to get these dynamically created...
2
by: Radu | last post by:
Hi. I have a page with the following html: __________________________________________________________ <h1>Dynamic Controls Test</h1> <hr /> <asp:TextBox ID="txtProduct1" Text="txtProduct 1"...
1
by: johnjsforum | last post by:
Buddies, I have a web page to create HTML buttons dynamically as in the “formDivColorPicker” function ////////////////////////////////////////////////////////////////////////////////////...
1
by: semomaniz | last post by:
I have a form where i have created the form dynamically. First i manually added a panel control to the web page. Then i added another panel dynamically and inside this panel i created tables. I have...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.