By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,288 Members | 1,098 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,288 IT Pros & Developers. It's quick & easy.

general question concerning dynamically created buttons

P: n/a
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
Share this Question
Share on Google+
2 Replies

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.