473,545 Members | 1,224 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

placing dynamic controls?

Hi peeps,

I'm trying to create some controls textboxes at runtime, based on the number
of items in a IETreeView that are checked. That I can do, I've got a place
holder and I can create the corrent number of controls.

The problem is that they appear next to each other.

I want to create the controls with some wording to the left of them (again,
dynamically generated). Normally id use <table> with two colums, one for the
text, and the other for the TextBox.

How can I do this with the Place Holder? I tried using a DIV, I could add
the controls to the DIV, but it threw a wobbly cos there was controls and
html. (something about it not containing a literal?).

So, how can I dynamically generate controls and then space them how I want
them?

Help!

Cheers
Dan
Nov 19 '05 #1
6 2229
Create a Table control, add TableRow, add TableCell and add the TextBox in
its Controls collection. Then add second TableCell and add the label.
Continue this way, adding the second TableRow.
Then add the Table control to the PlaceHolder.

Hope that helps!
Regards,
Kostadin Kostov

"dhnriversi de" wrote:
Hi peeps,

I'm trying to create some controls textboxes at runtime, based on the number
of items in a IETreeView that are checked. That I can do, I've got a place
holder and I can create the corrent number of controls.

The problem is that they appear next to each other.

I want to create the controls with some wording to the left of them (again,
dynamically generated). Normally id use <table> with two colums, one for the
text, and the other for the TextBox.

How can I do this with the Place Holder? I tried using a DIV, I could add
the controls to the DIV, but it threw a wobbly cos there was controls and
html. (something about it not containing a literal?).

So, how can I dynamically generate controls and then space them how I want
them?

Help!

Cheers
Dan

Nov 19 '05 #2
Hey

Thanks that worked great - I hadn't twigged that you could treat the HTML
elements as controls like that!

One slight prob... these controls are on an ASP:panel, which I set it's
visible property to true/false during execution.

If I set the visible to false and then true, all my controls are gone! How
can I fix this, and use ViewState to "remember" what values have been entered
into the controls?

Cheers
Dan

"Kostadin Kostov" wrote:
Create a Table control, add TableRow, add TableCell and add the TextBox in
its Controls collection. Then add second TableCell and add the label.
Continue this way, adding the second TableRow.
Then add the Table control to the PlaceHolder.

Hope that helps!
Regards,
Kostadin Kostov

"dhnriversi de" wrote:
Hi peeps,

I'm trying to create some controls textboxes at runtime, based on the number
of items in a IETreeView that are checked. That I can do, I've got a place
holder and I can create the corrent number of controls.

The problem is that they appear next to each other.

I want to create the controls with some wording to the left of them (again,
dynamically generated). Normally id use <table> with two colums, one for the
text, and the other for the TextBox.

How can I do this with the Place Holder? I tried using a DIV, I could add
the controls to the DIV, but it threw a wobbly cos there was controls and
html. (something about it not containing a literal?).

So, how can I dynamically generate controls and then space them how I want
them?

Help!

Cheers
Dan

Nov 19 '05 #3
Hi!
Well, when you make control like Panel invisible, you cannot use its
ViewState, neither you can use the controls inside it. A workaround that I ca
think of is instead of setting Visible=false, set style="display: none". Then,
I think, you can work with the child controls and ViewState.

Hope that helps!
Regards,
Kostadin Kostov

"dhnriversi de" wrote:
Hey

Thanks that worked great - I hadn't twigged that you could treat the HTML
elements as controls like that!

One slight prob... these controls are on an ASP:panel, which I set it's
visible property to true/false during execution.

If I set the visible to false and then true, all my controls are gone! How
can I fix this, and use ViewState to "remember" what values have been entered
into the controls?

Cheers
Dan

"Kostadin Kostov" wrote:
Create a Table control, add TableRow, add TableCell and add the TextBox in
its Controls collection. Then add second TableCell and add the label.
Continue this way, adding the second TableRow.
Then add the Table control to the PlaceHolder.

Hope that helps!
Regards,
Kostadin Kostov

"dhnriversi de" wrote:
Hi peeps,

I'm trying to create some controls textboxes at runtime, based on the number
of items in a IETreeView that are checked. That I can do, I've got a place
holder and I can create the corrent number of controls.

The problem is that they appear next to each other.

I want to create the controls with some wording to the left of them (again,
dynamically generated). Normally id use <table> with two colums, one for the
text, and the other for the TextBox.

How can I do this with the Place Holder? I tried using a DIV, I could add
the controls to the DIV, but it threw a wobbly cos there was controls and
html. (something about it not containing a literal?).

So, how can I dynamically generate controls and then space them how I want
them?

Help!

Cheers
Dan

Nov 19 '05 #4
Just tried that with Panel.Style.Add ("display", "none"); and the same thing
happens. The controls are there, and then it hides, and then when I go

Panel.Style.Add ("display", "inline") - there's nothing in it.

Having said that, the controls are within a DIV within the panel, and that
DIV is still there, but all the controls aren't.

The reason I'm hiding/showing is I'm trying to create a wizard looking
thing, and so I have next/back buttons. clicking next hides the panel and
shows the next one, clicking back hides that and shows the one with the
controls. Except they aren't there! :(

"Kostadin Kostov" wrote:
Hi!
Well, when you make control like Panel invisible, you cannot use its
ViewState, neither you can use the controls inside it. A workaround that I ca
think of is instead of setting Visible=false, set style="display: none". Then,
I think, you can work with the child controls and ViewState.

Hope that helps!
Regards,
Kostadin Kostov

"dhnriversi de" wrote:
Hey

Thanks that worked great - I hadn't twigged that you could treat the HTML
elements as controls like that!

One slight prob... these controls are on an ASP:panel, which I set it's
visible property to true/false during execution.

If I set the visible to false and then true, all my controls are gone! How
can I fix this, and use ViewState to "remember" what values have been entered
into the controls?

Cheers
Dan

"Kostadin Kostov" wrote:
Create a Table control, add TableRow, add TableCell and add the TextBox in
its Controls collection. Then add second TableCell and add the label.
Continue this way, adding the second TableRow.
Then add the Table control to the PlaceHolder.

Hope that helps!
Regards,
Kostadin Kostov

"dhnriversi de" wrote:

> Hi peeps,
>
> I'm trying to create some controls textboxes at runtime, based on the number
> of items in a IETreeView that are checked. That I can do, I've got a place
> holder and I can create the corrent number of controls.
>
> The problem is that they appear next to each other.
>
> I want to create the controls with some wording to the left of them (again,
> dynamically generated). Normally id use <table> with two colums, one for the
> text, and the other for the TextBox.
>
> How can I do this with the Place Holder? I tried using a DIV, I could add
> the controls to the DIV, but it threw a wobbly cos there was controls and
> html. (something about it not containing a literal?).
>
> So, how can I dynamically generate controls and then space them how I want
> them?
>
> Help!
>
> Cheers
>
>
> Dan

Nov 19 '05 #5
I have implemented wizard like functionality in web and I think that the best
approach is to redirect to a different page, instead of hiding/showing
different controls. And you use the Session object for saving the data you
need between the pages of the wizard. Of course it's up to you to choose an
approach, that best suites you.

Regards,
Kostadin Kostov

"dhnriversi de" wrote:
Just tried that with Panel.Style.Add ("display", "none"); and the same thing
happens. The controls are there, and then it hides, and then when I go

Panel.Style.Add ("display", "inline") - there's nothing in it.

Having said that, the controls are within a DIV within the panel, and that
DIV is still there, but all the controls aren't.

The reason I'm hiding/showing is I'm trying to create a wizard looking
thing, and so I have next/back buttons. clicking next hides the panel and
shows the next one, clicking back hides that and shows the one with the
controls. Except they aren't there! :(

"Kostadin Kostov" wrote:
Hi!
Well, when you make control like Panel invisible, you cannot use its
ViewState, neither you can use the controls inside it. A workaround that I ca
think of is instead of setting Visible=false, set style="display: none". Then,
I think, you can work with the child controls and ViewState.

Hope that helps!
Regards,
Kostadin Kostov

"dhnriversi de" wrote:
Hey

Thanks that worked great - I hadn't twigged that you could treat the HTML
elements as controls like that!

One slight prob... these controls are on an ASP:panel, which I set it's
visible property to true/false during execution.

If I set the visible to false and then true, all my controls are gone! How
can I fix this, and use ViewState to "remember" what values have been entered
into the controls?

Cheers
Dan

"Kostadin Kostov" wrote:

> Create a Table control, add TableRow, add TableCell and add the TextBox in
> its Controls collection. Then add second TableCell and add the label.
> Continue this way, adding the second TableRow.
> Then add the Table control to the PlaceHolder.
>
> Hope that helps!
> Regards,
> Kostadin Kostov
>
> "dhnriversi de" wrote:
>
> > Hi peeps,
> >
> > I'm trying to create some controls textboxes at runtime, based on the number
> > of items in a IETreeView that are checked. That I can do, I've got a place
> > holder and I can create the corrent number of controls.
> >
> > The problem is that they appear next to each other.
> >
> > I want to create the controls with some wording to the left of them (again,
> > dynamically generated). Normally id use <table> with two colums, one for the
> > text, and the other for the TextBox.
> >
> > How can I do this with the Place Holder? I tried using a DIV, I could add
> > the controls to the DIV, but it threw a wobbly cos there was controls and
> > html. (something about it not containing a literal?).
> >
> > So, how can I dynamically generate controls and then space them how I want
> > them?
> >
> > Help!
> >
> > Cheers
> >
> >
> > Dan

Nov 19 '05 #6
Kostadin,

Let me just check I've got this right, cos my code might be stuffed if what
I've just realised is true :)

So, I run my page, and it shows a TreeView, which I can check a number of
items and click a button. That removes that panel and shows the next panel.
The code here finds out which buttons are checked, and automatically
generates a table/label/textbox for each checked item.

You fill that in, then click next again. This causes a postback. Now, before
I set the panel with the dynamic controls to invisible, I run a function to
get the values out of the textboxes...

TextBox tx = new TextBox();
tx = (TextBox) Panel.FindContr ol("thetextboxi d");
string var = tx.Text;

Now then, this is crashing, saying that "object not set to an instance of an
object". Is that because I need to do FindControl on the Cell object I
created in the Row object of the Table object, or is it because my controls
are getting demolished on PostBack?

If it's the latter, that means I can never get the info out of the controls,
and my whole approach is stuffed!

Please reply :)

Cheers
Dan

"Kostadin Kostov" wrote:
I have implemented wizard like functionality in web and I think that the best
approach is to redirect to a different page, instead of hiding/showing
different controls. And you use the Session object for saving the data you
need between the pages of the wizard. Of course it's up to you to choose an
approach, that best suites you.

Regards,
Kostadin Kostov

"dhnriversi de" wrote:
Just tried that with Panel.Style.Add ("display", "none"); and the same thing
happens. The controls are there, and then it hides, and then when I go

Panel.Style.Add ("display", "inline") - there's nothing in it.

Having said that, the controls are within a DIV within the panel, and that
DIV is still there, but all the controls aren't.

The reason I'm hiding/showing is I'm trying to create a wizard looking
thing, and so I have next/back buttons. clicking next hides the panel and
shows the next one, clicking back hides that and shows the one with the
controls. Except they aren't there! :(

"Kostadin Kostov" wrote:
Hi!
Well, when you make control like Panel invisible, you cannot use its
ViewState, neither you can use the controls inside it. A workaround that I ca
think of is instead of setting Visible=false, set style="display: none". Then,
I think, you can work with the child controls and ViewState.

Hope that helps!
Regards,
Kostadin Kostov

"dhnriversi de" wrote:

> Hey
>
> Thanks that worked great - I hadn't twigged that you could treat the HTML
> elements as controls like that!
>
> One slight prob... these controls are on an ASP:panel, which I set it's
> visible property to true/false during execution.
>
> If I set the visible to false and then true, all my controls are gone! How
> can I fix this, and use ViewState to "remember" what values have been entered
> into the controls?
>
> Cheers
>
>
> Dan
>
> "Kostadin Kostov" wrote:
>
> > Create a Table control, add TableRow, add TableCell and add the TextBox in
> > its Controls collection. Then add second TableCell and add the label.
> > Continue this way, adding the second TableRow.
> > Then add the Table control to the PlaceHolder.
> >
> > Hope that helps!
> > Regards,
> > Kostadin Kostov
> >
> > "dhnriversi de" wrote:
> >
> > > Hi peeps,
> > >
> > > I'm trying to create some controls textboxes at runtime, based on the number
> > > of items in a IETreeView that are checked. That I can do, I've got a place
> > > holder and I can create the corrent number of controls.
> > >
> > > The problem is that they appear next to each other.
> > >
> > > I want to create the controls with some wording to the left of them (again,
> > > dynamically generated). Normally id use <table> with two colums, one for the
> > > text, and the other for the TextBox.
> > >
> > > How can I do this with the Place Holder? I tried using a DIV, I could add
> > > the controls to the DIV, but it threw a wobbly cos there was controls and
> > > html. (something about it not containing a literal?).
> > >
> > > So, how can I dynamically generate controls and then space them how I want
> > > them?
> > >
> > > Help!
> > >
> > > Cheers
> > >
> > >
> > > Dan

Nov 19 '05 #7

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

Similar topics

1
6311
by: Will | last post by:
Hi all. I'm learning VB.Net and am developing a WinForms app. I'm trying to make an app that I will use to scan in one or more than on image. I want to use a tabbed interface to hold each image. Here's the code I'm using for testing purposes. I've got the code in the form's load event, but I think I'd have the same problems no matter where...
2
5300
by: theComputer7 | last post by:
I cut down the code to make this half way understandable... I have read Data Grid girls caution about over use of dynamic controls. I truly believe what I am doing requires dynamically inserted user controls. Worse I'm trying to add dynamic user controls from within a repeater loop (looping through attributes)... I bind to a function in...
3
3955
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which step you're on. This all works fine, but I ran into some trouble when I started creating controls dynamically in my code-behind file. Each panel...
0
1331
by: pbb | last post by:
I have a web page on which I dynamically create controls based on the selection a user makes from a dropdownlist (this ddl is not dynamic). Depending on the user's selection, the controls could be any combination of textboxes, ddls, popup calendars, etc. The properties of the dynamic controls are stored in a SQL database so that my program...
1
2178
by: Diffident | last post by:
Hello All, I am trying to add dynamic controls onto my page and here is how I am doing that. I have a page which has a button called as "AddMoreControls" and in this button's event handler I am creating controls dynamically and adding them to a panel on the page. For example, if the button is clicked once, the page is posted back and the...
9
3612
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have to create the dynamic controls in the OnInit stage of the lifecycle. Since data from static controls is not yet available in the OnInit stage I...
1
4645
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by pressing Remove button the selecetd row will be...
0
3475
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button ,another row...
2
5010
by: englishman69 | last post by:
Hello, I have been banging my head against this one for a while... Searches online have revealed many different proposals for correcting my issue but none that I can follow! My basic situation is this, I have a page which uses multiple postbacks to generate a list of dynamic text boxes with appropriate labels. However, when I do the final...
0
7465
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...
0
7398
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...
0
7656
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7805
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...
1
7416
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...
0
7752
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...
1
5325
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...
0
3441
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.