473,479 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Retrieving values in user control placed in placeholder ctrl

Joe
Hello All,

I have a user control which is composed of a label and a dropdownlist. In
my code I add the user control to a placeholder on the webform. Now I want
to be able to retrieve the selected value from the drop downlist when a user
clicks a button server control.

Here is the code that populates the user control and placeholder:

Dim UControl As AugmentedDropDownList =
CType(LoadControl("../UserControls/AugmentedDropDownList.ascx"),
AugmentedDropDownList)

UControl.PopulateDropDownList(Control.Attributes(" name").Value, DropDownNode)

plcContent.Controls.Add(UControl)

The first parameter in the PopulateDropDownList method contains the caption
for the label. The DropDownNode is an XmlNode that has the values of the
dropdownlist along with the values for the individual ListItems.

I can not figure out how to retrieve the values from the DropDownList in the
User Control. If any of you have any ideas, please let me know what they are.

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation
Dec 13 '05 #1
1 2902
Working with dynamic controls can be tricky. You need to make sure that the
controls are available and in the Controls collection before the posted data
is processed. That usually means initializing all dynamic controls in the
Init event so that the page looks exactly like it was when it was sent to
the browser. That way ASP.NET can locate the control whose posted data was
submitted.

Another way would be to access the posted data directly using the old
fashioned way of Page.Request.Form (or something like that).

Does this help?

"Joe" <jo******@donotspam.yahoo.com> wrote in message
news:08**********************************@microsof t.com...
Hello All,

I have a user control which is composed of a label and a dropdownlist. In
my code I add the user control to a placeholder on the webform. Now I
want
to be able to retrieve the selected value from the drop downlist when a
user
clicks a button server control.

Here is the code that populates the user control and placeholder:

Dim UControl As AugmentedDropDownList =
CType(LoadControl("../UserControls/AugmentedDropDownList.ascx"),
AugmentedDropDownList)

UControl.PopulateDropDownList(Control.Attributes(" name").Value,
DropDownNode)

plcContent.Controls.Add(UControl)

The first parameter in the PopulateDropDownList method contains the
caption
for the label. The DropDownNode is an XmlNode that has the values of the
dropdownlist along with the values for the individual ListItems.

I can not figure out how to retrieve the values from the DropDownList in
the
User Control. If any of you have any ideas, please let me know what they
are.

TIA,
--
Joe

VB.NET/C#/ASP.NET/ASP/VB/C++/Web and DB development/VBA Automation

Dec 13 '05 #2

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

Similar topics

1
1970
by: DotNetGruven | last post by:
Can I create a custom validator control in my project and add it to a PlaceHolder on my ASPX page?? Here is what I've tried. It compiles and runs without error, but doesn't detected that the...
1
1757
by: Stu | last post by:
Hi, I have created a Web User Control (vb.net) that I want to display on a placeholder on the page when a button is pressed. The control 'DeleteImage' is a blank control with 2 buttons added at...
7
6352
by: Tom wilson | last post by:
I'm trying to create dynamic controls in ASP.Net. It's driving me nuts. I keep getting the error: Control '16' of type 'RadioButton' must be placed inside a form tag with runat=server. Dim...
3
5141
by: John Hughes | last post by:
I'm trying to add a user control to a form via the pages render method and I get the following error : "Control 'Button1' of type 'Button' must be placed inside a form tag with runat=server" ...
4
1675
by: tshad | last post by:
Is there a way for a User Control to access an object (such as label or textbox) on the .aspx page that calls it? For example: x.aspx ************************************** .... Sub...
2
4388
by: Nick | last post by:
I have two navigation user controls and based on a query string will load one or the other. On the page that will load the user control I cannot do the following Dim uc As FlashNavigation (The...
0
1125
by: jburnage | last post by:
I need help in getting the values from a dynamically added user control when a user submits a form. The controls are added to a placeholder and this all works fine - but its looping through the...
6
10095
by: alun65 | last post by:
I'm having trouble programmatically adding a user control and then setting some of it's server controls. I add the user control to the code behind and add it to a placeholder: protected void...
5
2676
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hallo, I have a radiobuttonlist control that is added on a custom Web User Control. This control has a property that exposes the SelectedIndex property of the embedded radiobuttonlist. When...
0
7019
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
7067
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...
1
6719
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...
0
5312
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,...
0
4463
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...
0
2980
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1288
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 ...
1
555
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
166
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...

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.