473,795 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamically adding controls question

djc
I have something like the following:
---------------------------------------------------

Dim btnAddUpdateDet ail As New LinkButton()
btnAddUpdateDet ail.Text = "Add/Update Issue Detail"
btnAddUpdateDet ail.CommandName = "AddUpdateDetai l"
AddHandler btnAddUpdateDet ail.Command, AddressOf HandleActions
ActionsPanel.Co ntrols.Add(btnA ddUpdateDetail)

Dim BR1 As New Literal()
BR1.Text = "<br/>"
ActionsPanel.Co ntrols.Add(BR1)

Dim btnChangeType As New LinkButton()
btnChangeType.T ext = "Change this issue's type"
btnChangeType.C ommandName = "ChangeIssueTyp e"
AddHandler btnChangeType.C ommand, AddressOf HandleActions
ActionsPanel.Co ntrols.Add(btnC hangeType)

Dim BR2 As New Literal() BR2.Text = "<br/>"
ActionsPanel.Co ntrols.Add(BR2)
-------------------------------------------------------

1) is there a better way to do this that would relieve me of having to
create a seperate variable for each Literal control that is used to insert a
<br/> tag? I am dynamically loading these buttons based on some criteria and
there could be up to 6 or 7 buttons needed based on like 10 different
scenarios. The above example is just a small snippet of the code. I am using
a SELECT CASE statment and each case may have code like the example with up
to 6 or 7 buttons to create, each with a <br/> after them. There must be a
better way.
Nov 18 '05 #1
2 1093
you can use the same variable, or standard refactoring principles would tell
you to make a function that returns a literal <br> that you call. in fact,
the pattern may be to create the button and the br, just pass the container,
text, commandname and callback routine.

-- bruce (sqlwork.com)
"djc" <no***@nowhere. com> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
| I have something like the following:
| ---------------------------------------------------
|
| Dim btnAddUpdateDet ail As New LinkButton()
| btnAddUpdateDet ail.Text = "Add/Update Issue Detail"
| btnAddUpdateDet ail.CommandName = "AddUpdateDetai l"
| AddHandler btnAddUpdateDet ail.Command, AddressOf HandleActions
| ActionsPanel.Co ntrols.Add(btnA ddUpdateDetail)
|
| Dim BR1 As New Literal()
| BR1.Text = "<br/>"
| ActionsPanel.Co ntrols.Add(BR1)
|
| Dim btnChangeType As New LinkButton()
| btnChangeType.T ext = "Change this issue's type"
| btnChangeType.C ommandName = "ChangeIssueTyp e"
| AddHandler btnChangeType.C ommand, AddressOf HandleActions
| ActionsPanel.Co ntrols.Add(btnC hangeType)
|
| Dim BR2 As New Literal() BR2.Text = "<br/>"
| ActionsPanel.Co ntrols.Add(BR2)
| -------------------------------------------------------
|
| 1) is there a better way to do this that would relieve me of having to
| create a seperate variable for each Literal control that is used to insert
a
| <br/> tag? I am dynamically loading these buttons based on some criteria
and
| there could be up to 6 or 7 buttons needed based on like 10 different
| scenarios. The above example is just a small snippet of the code. I am
using
| a SELECT CASE statment and each case may have code like the example with
up
| to 6 or 7 buttons to create, each with a <br/> after them. There must be a
| better way.
|
|
Nov 18 '05 #2
djc
I got an error when I tried to use the same variable name. I'll check it out
again and post the error back here. Thanks for the reply.

"bruce barker" <no***********@ safeco.com> wrote in message
news:em******** ******@TK2MSFTN GP15.phx.gbl...
you can use the same variable, or standard refactoring principles would tell you to make a function that returns a literal <br> that you call. in fact,
the pattern may be to create the button and the br, just pass the container, text, commandname and callback routine.

-- bruce (sqlwork.com)
"djc" <no***@nowhere. com> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
| I have something like the following:
| ---------------------------------------------------
|
| Dim btnAddUpdateDet ail As New LinkButton()
| btnAddUpdateDet ail.Text = "Add/Update Issue Detail"
| btnAddUpdateDet ail.CommandName = "AddUpdateDetai l"
| AddHandler btnAddUpdateDet ail.Command, AddressOf HandleActions
| ActionsPanel.Co ntrols.Add(btnA ddUpdateDetail)
|
| Dim BR1 As New Literal()
| BR1.Text = "<br/>"
| ActionsPanel.Co ntrols.Add(BR1)
|
| Dim btnChangeType As New LinkButton()
| btnChangeType.T ext = "Change this issue's type"
| btnChangeType.C ommandName = "ChangeIssueTyp e"
| AddHandler btnChangeType.C ommand, AddressOf HandleActions
| ActionsPanel.Co ntrols.Add(btnC hangeType)
|
| Dim BR2 As New Literal() BR2.Text = "<br/>"
| ActionsPanel.Co ntrols.Add(BR2)
| -------------------------------------------------------
|
| 1) is there a better way to do this that would relieve me of having to
| create a seperate variable for each Literal control that is used to insert a
| <br/> tag? I am dynamically loading these buttons based on some criteria
and
| there could be up to 6 or 7 buttons needed based on like 10 different
| scenarios. The above example is just a small snippet of the code. I am
using
| a SELECT CASE statment and each case may have code like the example with
up
| to 6 or 7 buttons to create, each with a <br/> after them. There must be a | better way.
|
|

Nov 18 '05 #3

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

Similar topics

8
4317
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image button at runtime: //----- Code snippet protected System.Web.UI.WebControls.PlaceHolder ImageHolder; private void Page_Load(object sender, System.EventArgs e)
2
2914
by: Chad | last post by:
I have a problem that I am desperate to understand. It involves dynamically adding controls to a Table control that is built as a result of performing a database query. I am not looking to avoid the problem by avoiding the table control or resorting to databound controls that better manage state for me. I hope to understand how to solve the problem by using the Table web control and sticking to the approach of building the table at run...
2
4571
by: Patrick | last post by:
I want to define a set of web-form templates in XML and render the equivalent web-form with ASP.NET, then process any input server controls on the form. Reading the XML file from Page_load is easy, but 1) How do I set about dynamically creating user controls (like TextBox, TextArea) --- simply Declare and initialised (new) the user controls?? How do I "place" it graphically on the form. Ideally, I want them to lay out in a table, one...
1
2065
by: Jeffrey Todd | last post by:
I have successfully created functionality that mostly models what I'm trying to do - which is dynamically insert controls into a user control (ascx), and insert validation controls, also dynamically, for some of the inserted controls. The controls (e.g., textBoxes) get created correctly and viewstate is maintained across postbacks, etc - BUT there is an issue with the validation controls. The validation controls, themselves are...
0
2409
by: Mike Collins | last post by:
I someone can please help, I am about at an end in trying to figure this out. I am adding some dynamic controls to my page (I found out that I was supposed to be doing that in the oninit event, which I am). I now want to read the text/values of those controls. I have found out that I can read the values if I wait until Page_Load, but then I have the same questions showing up again (along with the new questions) and I do not want them to....
3
2197
by: Ben Dewey | last post by:
Okay, so I have a base Page class called ArticlesPageBase. This base class has reads in an overridable ArticleId and Loads the data into a Panel object in the ContentPlaceHolder of the Master. The article that it loads from the Database is a xml field that contains html code for the article. I added some custom html to the database article called <question id="22" /> When the article contains inline questions are parse out the start...
3
5497
by: Mark Denardo | last post by:
I'm trying to dynamically create and add controls to a web page: Label obj1 = new Label(); DropDownList obj2 = new DropDownList(); Controls.Add(obj1); Controls.Add(obj2); But I get the following error when the DDL is added (but not the Label): "Control 'ctl07' of type 'DropDownList' must be placed inside a form tag
6
11082
by: | last post by:
I have made some user controls with custom properties. I can set those properties on instances of my user controls, and I have programmed my user control to do useful visual things in response to how those properties are set. I want to be able to do two other things: a) add User control instances to my page, filling in the place of placeholder controls, and b) programmatically setting custom properties on those dynamically spawned...
3
3687
by: Mat | last post by:
Hi all, It's been a long while since I've posted or used access and one of the things that had me stop was the realisation I couldn't dynamically add new controls to a form. I am using Access 97/2000. So I guess my questions are: First up, a double check - You can't dynamically add controls to access 97/2000 forms right?
1
4915
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
9672
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
9519
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,...
0
10214
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10164
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
9042
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...
1
7540
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6780
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
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
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 we have to send another system

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.