473,765 Members | 2,066 Online
Bytes | Software Development & Data Engineering Community
+ 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 1947
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*********@me gapathdsl.net> wrote in message
news:O3******** ******@TK2MSFTN GP12.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******** ******@TK2MSFTN GP10.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*********@me gapathdsl.net> wrote in message
news:O3******** ******@TK2MSFTN GP12.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
1131
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 works fine -- provided that the buttons are added "early enough", that is, before the Form_Load. If I try to add the buttons after the Form_Load, the buttons do get added but there is a bad side effect. Namely, the button images for all the...
1
2588
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 LinkButton myLB = new LinkButton(); ......... .........
1
1499
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 I am creating a "process framework" that allows for common web controls to be linked together in a procedural fashion, and will also allow for code to be added to these controls (IE New button events, etc). I have basically created a static...
3
8526
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 run time and the number may vary, we can't statically tie to the event to a control. I'm assuming I need to dynamically add event handlers at run time, and that one method could act as the event handler, with unique event args being created for...
2
4577
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 event handler for the click event. The problem is that when I click the button on the page and view the locals window in debug mode, I don't see any information on the button control. Say, I want to create a variable number of buttons based on...
5
6760
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 link buttons to stay wired up to their click events. I have what is basically a simply survey question generation page. The page first displays a few static fields and a dropdownlist of various options for the user to select. When the user...
2
1814
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" runat="server"></ asp:TextBox> <asp:Button ID="cmdAddRow" Text="+" AccessKey="+" runat="server" /> <asp:Button ID="cmdSubtractRow" Text="-" AccessKey="+" runat="server" / <asp:PlaceHolder runat="server" id="placeTextBoxes" />
1
2283
by: johnjsforum | last post by:
Buddies, I have a web page to create HTML buttons dynamically as in the “formDivColorPicker” function //////////////////////////////////////////////////////////////////////////////////// version 1 : using global variables ////////////////////////////////////////////////////////////////// var _textField, _divColorPicker; // global vars window.onload = function() { _textField = document.getElementById('htxaMessage'); // fill...
1
4912
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 set text boxes and labels inside the table rows. I then added a button. All of these are done through code. The problem that i am having is i can get the value from a text box with resides inside the first panel (out side of panel that is...
0
9568
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
9959
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9835
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8833
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6649
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.