473,763 Members | 5,412 Online
Bytes | Software Development & Data Engineering Community
+ 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 AugmentedDropDo wnList =
CType(LoadContr ol("../UserControls/AugmentedDropDo wnList.ascx"),
AugmentedDropDo wnList)

UControl.Popula teDropDownList( Control.Attribu tes("name").Val ue, DropDownNode)

plcContent.Cont rols.Add(UContr ol)

The first parameter in the PopulateDropDow nList 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 2925
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.Fo rm (or something like that).

Does this help?

"Joe" <jo******@donot spam.yahoo.com> wrote in message
news:08******** *************** ***********@mic rosoft.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 AugmentedDropDo wnList =
CType(LoadContr ol("../UserControls/AugmentedDropDo wnList.ascx"),
AugmentedDropDo wnList)

UControl.Popula teDropDownList( Control.Attribu tes("name").Val ue,
DropDownNode)

plcContent.Cont rols.Add(UContr ol)

The first parameter in the PopulateDropDow nList 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
1987
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 checkbox it is validating is checked when the form is submitted. TIA, George
1
1777
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 design time (cancel/accept). However, if I add a reponse.write("hello world") in the page load handler the text appears to shhow the control is actually loding & firing to some extent, but there is no sign of the buttons! Am I missing something...
7
6398
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 Place1 As New PlaceHolder Controls.Add(Place1) For y = 1 To Choices.RecordCount Choices.MoveTo(y)
3
5169
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" The user control has this button on its page. I am outputing the <form runat="server"> inside the render method and have also tried adding it to the page and to the control without any luck. Any help appreciated.
4
1685
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 Page_Load(s as Object, e as EventArgs) LoadControl("x.ascx")
2
4406
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 name of the code behind class) I also can't do CType(uc, FlashNavigation) I get Type 'FlashNavigation' is not defined. How can I dynamically load a user control then access it's properties and or methods?
0
1136
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 controls that i'm having trouble with. Its the "case 1:" statement that i need help with cheers in advance for any help my code is as follows. // a Property that manages a counter stored in ViewState protected int NumberOfSchemeControls
6
10123
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 Page_Load(object sender, EventArgs e) { UserControls_WebUserControl myControl = new UserControls_WebUserControl(); PlaceHolder1.Controls.Add(web);
5
2691
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 running this in IE, behaviour is as I would expect it. If I select an item and do a postback, the page remembers my selection when reloading, and the SelectedIndex property of my control returns the correct value.
0
9386
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
10144
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9937
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
9822
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7366
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
6642
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
5270
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3522
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.