Dynamic Controls - Still!

C

Coleen

Hi Jim Thanks for your help.

I changed the table from an ASP.Net table to an HTML table. I am till
having the problem of the control placed inside the table not triggering the
on SelectedIndexChanged event. To be honest, I don't have a clue what you
are talking about as to containers and panels - I'm sorry. Can you please
send me a link to an example on how to do this? So far, everything I've
tried has not worked.

What I have to have happen is the on the dropdown selection, I need a set of
labels and text boxes to appear to allow the user to enter data pertaining
to the payment type. I wanted to use a table for alignment purposes, but I
don't have to. I DO have to dynamically have the text in the labels change,
and I DO have to have the on SelectedItemChanged or SelectedIndexChanged
event be triggered. Do you have any suggestions, links to examples, etc.
that you could point me to? Thanks so very much for your help :)

Coleen

From: Jim Cheshire (e-mail address removed)

Coleen,

It doesn't matter. The panel is added during design-time and you can put
it anywhere. It's simply a placeholder for the dynamic controls that will
be added later.

[MSFT]
MCP+I, MCSE, MCSD, MCDBA
ASP.NET Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
From: "Coleen" <[email protected]>

I guess I'm a little confused. Does the table get placed inside the
container? I've never used containers before, so I honestly don't have a
clue where to start coding..."just add the controls to the Controls
collection of pnlControls" is the control created and then the entire
table placed inside, or is the container placed inside the table?


Coleen,

A table is fine. The thing is that you need to add your dynamic
controls to a container other than the page. In other words, suppose you
were
adding them to a Panel control called pnlControls. You would just add
the controls to the Controls collection of pnlControls.

pnlControls.Controls.Add(myControl)

That will prevent the controls from getting added outside of the <form
tag and causing a problem.
Jim Cheshire [MSFT]
 
J

Jim Cheshire [MSFT]

Coleen,

Are you dynamically creating a different set of controls based upon some
condition? The reason I ask is that it might be a lot easier to just add a
panel and change the Visible property.

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
ASP.NET Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.


--------------------
| From: "Coleen" <[email protected]>
| Subject: Dynamic Controls - Still!
| Date: Fri, 12 Nov 2004 10:47:28 -0800
| Lines: 61
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| NNTP-Posting-Host: virt27212.virtual.state.nv.us 167.154.27.212
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11
.phx.gbl
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.aspnet.buildingcontrols:11664
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
|
| Hi Jim Thanks for your help.
|
| I changed the table from an ASP.Net table to an HTML table. I am till
| having the problem of the control placed inside the table not triggering
the
| on SelectedIndexChanged event. To be honest, I don't have a clue what you
| are talking about as to containers and panels - I'm sorry. Can you please
| send me a link to an example on how to do this? So far, everything I've
| tried has not worked.
|
| What I have to have happen is the on the dropdown selection, I need a set
of
| labels and text boxes to appear to allow the user to enter data pertaining
| to the payment type. I wanted to use a table for alignment purposes, but
I
| don't have to. I DO have to dynamically have the text in the labels
change,
| and I DO have to have the on SelectedItemChanged or SelectedIndexChanged
| event be triggered. Do you have any suggestions, links to examples, etc.
| that you could point me to? Thanks so very much for your help :)
|
| Coleen
|
| From: Jim Cheshire (e-mail address removed)
|
| Coleen,
|
| It doesn't matter. The panel is added during design-time and you can put
| it anywhere. It's simply a placeholder for the dynamic controls that will
| be added later.
|
| [MSFT]
| MCP+I, MCSE, MCSD, MCDBA
| ASP.NET Developer Support
| (e-mail address removed)
|
| This post is provided "AS-IS" with no warranties and confers no rights.
|
| --------------------
| From: "Coleen" <[email protected]>
|
| I guess I'm a little confused. Does the table get placed inside the
| container? I've never used containers before, so I honestly don't have a
| clue where to start coding..."just add the controls to the Controls
| collection of pnlControls" is the control created and then the entire
| table placed inside, or is the container placed inside the table?
|
|
| | Coleen,
|
| A table is fine. The thing is that you need to add your dynamic
| controls to a container other than the page. In other words, suppose you
| were
| adding them to a Panel control called pnlControls. You would just add
| the controls to the Controls collection of pnlControls.
|
| pnlControls.Controls.Add(myControl)
|
| That will prevent the controls from getting added outside of the <form
| tag and causing a problem.
| Jim Cheshire [MSFT]
|
|
|
 
C

Coleen

Yes. Depending on the payment type, I need the labels and associated
textboxes to be dynamically populated. I.e., if it is a credit card, I need
them to enter credit card data, if it's ant Electronic Funds transfer, a
different set and so on. I want these to populate according to what is
selected from the Dropdownlistbox, but when I place the ddl inside of a
table (either HTML or ASPX) the SelectedIndexChanged event does not trigger.
I am fairly new to VB .Net, but fairly adept at VB6. I am not familiar with
Panels. If you have a site or example that explains them better than the
..Net Help, I'd really appreciate it. I REALLY appreciate all of your help &
responses :)

Coleen

Jim Cheshire said:
Coleen,

Are you dynamically creating a different set of controls based upon some
condition? The reason I ask is that it might be a lot easier to just add a
panel and change the Visible property.

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
ASP.NET Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.


--------------------
| From: "Coleen" <[email protected]>
| Subject: Dynamic Controls - Still!
| Date: Fri, 12 Nov 2004 10:47:28 -0800
| Lines: 61
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| NNTP-Posting-Host: virt27212.virtual.state.nv.us 167.154.27.212
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11
phx.gbl
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.aspnet.buildingcontrols:11664
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
|
| Hi Jim Thanks for your help.
|
| I changed the table from an ASP.Net table to an HTML table. I am till
| having the problem of the control placed inside the table not triggering
the
| on SelectedIndexChanged event. To be honest, I don't have a clue what you
| are talking about as to containers and panels - I'm sorry. Can you please
| send me a link to an example on how to do this? So far, everything I've
| tried has not worked.
|
| What I have to have happen is the on the dropdown selection, I need a set
of
| labels and text boxes to appear to allow the user to enter data pertaining
| to the payment type. I wanted to use a table for alignment purposes, but
I
| don't have to. I DO have to dynamically have the text in the labels
change,
| and I DO have to have the on SelectedItemChanged or SelectedIndexChanged
| event be triggered. Do you have any suggestions, links to examples, etc.
| that you could point me to? Thanks so very much for your help :)
|
| Coleen
|
| From: Jim Cheshire (e-mail address removed)
|
| Coleen,
|
| It doesn't matter. The panel is added during design-time and you can put
| it anywhere. It's simply a placeholder for the dynamic controls that will
| be added later.
|
| [MSFT]
| MCP+I, MCSE, MCSD, MCDBA
| ASP.NET Developer Support
| (e-mail address removed)
|
| This post is provided "AS-IS" with no warranties and confers no rights.
|
| --------------------
| From: "Coleen" <[email protected]>
|
| I guess I'm a little confused. Does the table get placed inside the
| container? I've never used containers before, so I honestly don't have a
| clue where to start coding..."just add the controls to the Controls
| collection of pnlControls" is the control created and then the entire
| table placed inside, or is the container placed inside the table?
|
|
| | Coleen,
|
| A table is fine. The thing is that you need to add your dynamic
| controls to a container other than the page. In other words, suppose you
| were
| adding them to a Panel control called pnlControls. You would just add
| the controls to the Controls collection of pnlControls.
|
| pnlControls.Controls.Add(myControl)
|
| That will prevent the controls from getting added outside of the <form
| tag and causing a problem.
| Jim Cheshire [MSFT]
|
|
|
 
J

Jim Cheshire [MSFT]

Coleen,

I don't really have an example. You just drag and drop the panel on the
page and then name it. A panel derives from Control just like the Page
object. Therefore, it has a Controls collection just like a Page.

I just tried what you're doing and it works fine for me. Here's what I did:

1. Created a new HTML table.
2. Set cell TD1 to runat server.
3. Added this code to Page_Load:

Dim ddl As DropDownList = New DropDownList

With ddl
.Items.Add("Item1")
.Items.Add("Item2")
.AutoPostBack = True
End With

AddHandler ddl.SelectedIndexChanged, AddressOf Me.ddl_SelectedIndexChanged

I then added a subprocedure like this:

Private Sub ddl_OnSelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs)
' do nothing...
End Sub

When I set a breakpoint on that event, it hits it fine. Is it possible
that you haven't set the AutoPostBack property?

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
ASP.NET Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.



--------------------
| From: "Coleen" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: Re: Dynamic Controls - Still!
| Date: Fri, 12 Nov 2004 11:41:43 -0800
| Lines: 129
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
| Message-ID: <u8iD6#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| NNTP-Posting-Host: virt27212.virtual.state.nv.us 167.154.27.212
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10
..phx.gbl
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.aspnet.buildingcontrols:11667
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
|
| Yes. Depending on the payment type, I need the labels and associated
| textboxes to be dynamically populated. I.e., if it is a credit card, I
need
| them to enter credit card data, if it's ant Electronic Funds transfer, a
| different set and so on. I want these to populate according to what is
| selected from the Dropdownlistbox, but when I place the ddl inside of a
| table (either HTML or ASPX) the SelectedIndexChanged event does not
trigger.
| I am fairly new to VB .Net, but fairly adept at VB6. I am not familiar
with
| Panels. If you have a site or example that explains them better than the
| .Net Help, I'd really appreciate it. I REALLY appreciate all of your
help &
| responses :)
|
| Coleen
|
| | > Coleen,
| >
| > Are you dynamically creating a different set of controls based upon some
| > condition? The reason I ask is that it might be a lot easier to just
add
| a
| > panel and change the Visible property.
| >
| > Jim Cheshire [MSFT]
| > MCP+I, MCSE, MCSD, MCDBA
| > ASP.NET Developer Support
| > (e-mail address removed)
| >
| > This post is provided "AS-IS" with no warranties and confers no rights.
| >
| >
| > --------------------
| > | From: "Coleen" <[email protected]>
| > | Subject: Dynamic Controls - Still!
| > | Date: Fri, 12 Nov 2004 10:47:28 -0800
| > | Lines: 61
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
| > | Message-ID: <[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| > | NNTP-Posting-Host: virt27212.virtual.state.nv.us 167.154.27.212
| > | Path:
| >
|
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11
| > phx.gbl
| > | Xref: cpmsftngxa10.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.buildingcontrols:11664
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| > |
| > | Hi Jim Thanks for your help.
| > |
| > | I changed the table from an ASP.Net table to an HTML table. I am till
| > | having the problem of the control placed inside the table not
triggering
| > the
| > | on SelectedIndexChanged event. To be honest, I don't have a clue what
| you
| > | are talking about as to containers and panels - I'm sorry. Can you
| please
| > | send me a link to an example on how to do this? So far, everything
I've
| > | tried has not worked.
| > |
| > | What I have to have happen is the on the dropdown selection, I need a
| set
| > of
| > | labels and text boxes to appear to allow the user to enter data
| pertaining
| > | to the payment type. I wanted to use a table for alignment purposes,
| but
| > I
| > | don't have to. I DO have to dynamically have the text in the labels
| > change,
| > | and I DO have to have the on SelectedItemChanged or
SelectedIndexChanged
| > | event be triggered. Do you have any suggestions, links to examples,
| etc.
| > | that you could point me to? Thanks so very much for your help :)
| > |
| > | Coleen
| > |
| > | From: Jim Cheshire (e-mail address removed)
| > |
| > | Coleen,
| > |
| > | It doesn't matter. The panel is added during design-time and you can
| put
| > | it anywhere. It's simply a placeholder for the dynamic controls that
| will
| > | be added later.
| > |
| > | [MSFT]
| > | MCP+I, MCSE, MCSD, MCDBA
| > | ASP.NET Developer Support
| > | (e-mail address removed)
| > |
| > | This post is provided "AS-IS" with no warranties and confers no
rights.
| > |
| > | --------------------
| > | From: "Coleen" <[email protected]>
| > |
| > | I guess I'm a little confused. Does the table get placed inside the
| > | container? I've never used containers before, so I honestly don't
have
| a
| > | clue where to start coding..."just add the controls to the Controls
| > | collection of pnlControls" is the control created and then the entire
| > | table placed inside, or is the container placed inside the table?
| > |
| > |
message
| > | | > | Coleen,
| > |
| > | A table is fine. The thing is that you need to add your dynamic
| > | controls to a container other than the page. In other words, suppose
| you
| > | were
| > | adding them to a Panel control called pnlControls. You would just
add
| > | the controls to the Controls collection of pnlControls.
| > |
| > | pnlControls.Controls.Add(myControl)
| > |
| > | That will prevent the controls from getting added outside of the
<form
| > | tag and causing a problem.
| > | Jim Cheshire [MSFT]
| > |
| > |
| > |
| >
|
|
|
 
C

Coleen

I've got another page where the same code works just fine, but the labels
and textboxes are not nestled inside of any sort of a table. I am checking
for postback = false in the page that works. I tried to create my page in
the exact same manner as the page that does work, and it is still not
triggering the SelectedIndexChanged vent. I tried changing it to work when
the postback = true, but am still having trouble. Argh! This is not
logical! Thanks for your example I will try it and let you know what
happens.

I appreciate your time & effort.

Coleen


Jim Cheshire said:
Coleen,

I don't really have an example. You just drag and drop the panel on the
page and then name it. A panel derives from Control just like the Page
object. Therefore, it has a Controls collection just like a Page.

I just tried what you're doing and it works fine for me. Here's what I did:

1. Created a new HTML table.
2. Set cell TD1 to runat server.
3. Added this code to Page_Load:

Dim ddl As DropDownList = New DropDownList

With ddl
.Items.Add("Item1")
.Items.Add("Item2")
.AutoPostBack = True
End With

AddHandler ddl.SelectedIndexChanged, AddressOf Me.ddl_SelectedIndexChanged

I then added a subprocedure like this:

Private Sub ddl_OnSelectedIndexChanged(ByVal sender As Object, ByVal e As
System.EventArgs)
' do nothing...
End Sub

When I set a breakpoint on that event, it hits it fine. Is it possible
that you haven't set the AutoPostBack property?

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
ASP.NET Developer Support
(e-mail address removed)

This post is provided "AS-IS" with no warranties and confers no rights.



--------------------
| From: "Coleen" <[email protected]>
| References: <[email protected]>
<[email protected]>
| Subject: Re: Dynamic Controls - Still!
| Date: Fri, 12 Nov 2004 11:41:43 -0800
| Lines: 129
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
| Message-ID: <u8iD6#[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| NNTP-Posting-Host: virt27212.virtual.state.nv.us 167.154.27.212
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10
phx.gbl
| Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.aspnet.buildingcontrols:11667
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
|
| Yes. Depending on the payment type, I need the labels and associated
| textboxes to be dynamically populated. I.e., if it is a credit card, I
need
| them to enter credit card data, if it's ant Electronic Funds transfer, a
| different set and so on. I want these to populate according to what is
| selected from the Dropdownlistbox, but when I place the ddl inside of a
| table (either HTML or ASPX) the SelectedIndexChanged event does not
trigger.
| I am fairly new to VB .Net, but fairly adept at VB6. I am not familiar
with
| Panels. If you have a site or example that explains them better than the
| .Net Help, I'd really appreciate it. I REALLY appreciate all of your
help &
| responses :)
|
| Coleen
|
| | > Coleen,
| >
| > Are you dynamically creating a different set of controls based upon some
| > condition? The reason I ask is that it might be a lot easier to just
add
| a
| > panel and change the Visible property.
| >
| > Jim Cheshire [MSFT]
| > MCP+I, MCSE, MCSD, MCDBA
| > ASP.NET Developer Support
| > (e-mail address removed)
| >
| > This post is provided "AS-IS" with no warranties and confers no rights.
| >
| >
| > --------------------
| > | From: "Coleen" <[email protected]>
| > | Subject: Dynamic Controls - Still!
| > | Date: Fri, 12 Nov 2004 10:47:28 -0800
| > | Lines: 61
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
| > | Message-ID: <[email protected]>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| > | NNTP-Posting-Host: virt27212.virtual.state.nv.us 167.154.27.212
| > | Path:
| >
|
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11
| > phx.gbl
| > | Xref: cpmsftngxa10.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.buildingcontrols:11664
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| > |
| > | Hi Jim Thanks for your help.
| > |
| > | I changed the table from an ASP.Net table to an HTML table. I am till
| > | having the problem of the control placed inside the table not
triggering
| > the
| > | on SelectedIndexChanged event. To be honest, I don't have a clue what
| you
| > | are talking about as to containers and panels - I'm sorry. Can you
| please
| > | send me a link to an example on how to do this? So far, everything
I've
| > | tried has not worked.
| > |
| > | What I have to have happen is the on the dropdown selection, I need a
| set
| > of
| > | labels and text boxes to appear to allow the user to enter data
| pertaining
| > | to the payment type. I wanted to use a table for alignment purposes,
| but
| > I
| > | don't have to. I DO have to dynamically have the text in the labels
| > change,
| > | and I DO have to have the on SelectedItemChanged or
SelectedIndexChanged
| > | event be triggered. Do you have any suggestions, links to examples,
| etc.
| > | that you could point me to? Thanks so very much for your help :)
| > |
| > | Coleen
| > |
| > | From: Jim Cheshire (e-mail address removed)
| > |
| > | Coleen,
| > |
| > | It doesn't matter. The panel is added during design-time and you can
| put
| > | it anywhere. It's simply a placeholder for the dynamic controls that
| will
| > | be added later.
| > |
| > | [MSFT]
| > | MCP+I, MCSE, MCSD, MCDBA
| > | ASP.NET Developer Support
| > | (e-mail address removed)
| > |
| > | This post is provided "AS-IS" with no warranties and confers no
rights.
| > |
| > | --------------------
| > | From: "Coleen" <[email protected]>
| > |
| > | I guess I'm a little confused. Does the table get placed inside the
| > | container? I've never used containers before, so I honestly don't
have
| a
| > | clue where to start coding..."just add the controls to the Controls
| > | collection of pnlControls" is the control created and then the entire
| > | table placed inside, or is the container placed inside the table?
| > |
| > |
message
| > | | > | Coleen,
| > |
| > | A table is fine. The thing is that you need to add your dynamic
| > | controls to a container other than the page. In other words, suppose
| you
| > | were
| > | adding them to a Panel control called pnlControls. You would just
add
| > | the controls to the Controls collection of pnlControls.
| > |
| > | pnlControls.Controls.Add(myControl)
| > |
| > | That will prevent the controls from getting added outside of the
<form
| > | tag and causing a problem.
| > | Jim Cheshire [MSFT]
| > |
| > |
| > |
| >
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top