473,394 Members | 2,048 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,394 software developers and data experts.

dynamically adding controls question

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

Dim btnAddUpdateDetail As New LinkButton()
btnAddUpdateDetail.Text = "Add/Update Issue Detail"
btnAddUpdateDetail.CommandName = "AddUpdateDetail"
AddHandler btnAddUpdateDetail.Command, AddressOf HandleActions
ActionsPanel.Controls.Add(btnAddUpdateDetail)

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

Dim btnChangeType As New LinkButton()
btnChangeType.Text = "Change this issue's type"
btnChangeType.CommandName = "ChangeIssueType"
AddHandler btnChangeType.Command, AddressOf HandleActions
ActionsPanel.Controls.Add(btnChangeType)

Dim BR2 As New Literal() BR2.Text = "<br/>"
ActionsPanel.Controls.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 1078
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******************@TK2MSFTNGP09.phx.gbl...
| I have something like the following:
| ---------------------------------------------------
|
| Dim btnAddUpdateDetail As New LinkButton()
| btnAddUpdateDetail.Text = "Add/Update Issue Detail"
| btnAddUpdateDetail.CommandName = "AddUpdateDetail"
| AddHandler btnAddUpdateDetail.Command, AddressOf HandleActions
| ActionsPanel.Controls.Add(btnAddUpdateDetail)
|
| Dim BR1 As New Literal()
| BR1.Text = "<br/>"
| ActionsPanel.Controls.Add(BR1)
|
| Dim btnChangeType As New LinkButton()
| btnChangeType.Text = "Change this issue's type"
| btnChangeType.CommandName = "ChangeIssueType"
| AddHandler btnChangeType.Command, AddressOf HandleActions
| ActionsPanel.Controls.Add(btnChangeType)
|
| Dim BR2 As New Literal() BR2.Text = "<br/>"
| ActionsPanel.Controls.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**************@TK2MSFTNGP15.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******************@TK2MSFTNGP09.phx.gbl...
| I have something like the following:
| ---------------------------------------------------
|
| Dim btnAddUpdateDetail As New LinkButton()
| btnAddUpdateDetail.Text = "Add/Update Issue Detail"
| btnAddUpdateDetail.CommandName = "AddUpdateDetail"
| AddHandler btnAddUpdateDetail.Command, AddressOf HandleActions
| ActionsPanel.Controls.Add(btnAddUpdateDetail)
|
| Dim BR1 As New Literal()
| BR1.Text = "<br/>"
| ActionsPanel.Controls.Add(BR1)
|
| Dim btnChangeType As New LinkButton()
| btnChangeType.Text = "Change this issue's type"
| btnChangeType.CommandName = "ChangeIssueType"
| AddHandler btnChangeType.Command, AddressOf HandleActions
| ActionsPanel.Controls.Add(btnChangeType)
|
| Dim BR2 As New Literal() BR2.Text = "<br/>"
| ActionsPanel.Controls.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
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...
2
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...
2
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...
1
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...
0
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,...
3
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. ...
3
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...
6
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...
3
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...
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
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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:
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.