473,785 Members | 2,185 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display different type of controls from code behind in C#

1 New Member
Originally, I have the a panel with a drop down list and a radio button list (2 controls). Now user requests the capability to dynamically show the second control depending on user selection in the first control (drop down list). Sometimes the 2nd control can be a radiobuttonlist , sometimes the 2nd control can be another dropdownlist. How can I use code behind (in C#) to display the appropriate control at proper place of the panel?

Any suggestion is welcomed!

-----------------------
<asp:Panel ID="plMyPanel" runat="server">
<table border="0" cellpadding="0" width = "750px" id="table1" runat="server">
<tr>
<td align="right" style="width:20 %"><asp:Labe l ID ="lblOption1 " runat="server" Font-Bold="True" Width="83px"></asp:Label></td>
<td align="left" style="width: 51%"> <asp:DropDownLi st ID="ddlOption1 " Width = "410px" runat="server" CausesValidatio n="true"> </td>
<td style="width: 30%">&nbsp;</td>
</tr>
<tr>
<td valign="top" align="right" style="width:20 %; height: 34px;"><asp:Lab el ID ="lblOption2 " runat="server" Font-Bold="true"></asp:Label></td>
<td align="left" style="width:51 %">
<asp:RadioButto nList runat="server" ID="rblOption2 " RepeatDirection ="Vertical"> </asp:RadioButton List>
</td>
<td style="width:30 %">&nbsp;</td>
</tr>
</table>
</asp:Panel>
Dec 31 '07 #1
1 1862
dip_developer
648 Recognized Expert Contributor
[quote=bernie77]Originally, I have the a panel with a drop down list and a radio button list (2 controls). Now user requests the capability to dynamically show the second control depending on user selection in the first control (drop down list). Sometimes the 2nd control can be a radiobuttonlist , sometimes the 2nd control can be another dropdownlist. How can I use code behind (in C#) to display the appropriate control at proper place of the panel?

Any suggestion is welcomed!

you have to create control dynamically and add it to your panel.........a nd its easy enough....

Expand|Select|Wrap|Line Numbers
  1.  DropDownlist myddl; 
  2. myddl=New DropDownlist();
  3. Panel1.Controls.Add(myddl);
  4.  
Jan 2 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1078
by: m.ahrens | last post by:
Hi all my java script looks like: <script language="javascript"> function showProgress() { window.setTimeout('sleep()',2000); } function sleep()
1
1269
by: Chris Kettenbach | last post by:
Hi I am designing an ASP.net app. Just wanted some opinions on code behind options. My idea is to have a code behind file that the controls will reference and have ascx files for the controls. Then have the aspx pages call the controls. Is this a good approach? I wanted to throw all my business logic in to the code behind file and then on the aspx pages that use the controls just refernce the ascx files. Is this the correct approach?...
2
3115
by: Ric | last post by:
im new to asp.net. from what i understand, you have the aspx file (presentation), user-control(ascx file), code-behind(vb file) and components(compiled vb and dll files). the aspx file contains a reference to the ascx which can contain a reference to a component. can an aspx file contain a reference to an ascx file which contains a reference to a code-behind file? ive tried to do this then load the user-control via LoadControl(), but i...
171
7796
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles) like it because you can split the code from the design. That is logical. But if you are the only one working on the code, it seem a little overkill. I use Dreamweaver to do my design and find it a bit of a hassle to have multiple files open...
6
5516
by: Paolo Pignatelli | last post by:
I have an aspx code behind page that goes something like this in the HTML view: <asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%#"mailto:" &amp; DataBinder.Eval(Container.DataItem,"StoreEmail") &amp; "&amp;Subject=" &amp; DataBinder.Eval(Container.DataItem,"ProductName") ....
17
2717
by: tshad | last post by:
Many (if not most) have said that code-behind is best if working in teams - which does seem logical. How do you deal with the flow of the work? I have someone who is good at designing, but know nothing about ASP. He can build the design of the pages in HTML with tables, labels, textboxes etc. But then I would need to change them to ASP.net objects and write the code to make the page work (normally I do this as I go - can't do this...
19
3758
by: Alan Silver | last post by:
Hello, I have been developing ASP.NET with a text editor so far (better way to learn initially), and have now been trying Visual Web Developer. I want to create a project for an existing site and add the files to it. I can add my .aspx and .cs (code-behind) files, but VWD doesn't know which .cs file si the code-behind for any particular .aspx file. When you create a new aspx page in VWD, it automatically puts the code-behind file with...
9
4103
by: Alan Silver | last post by:
Hello, I have a user control which I am trying to load dynamically, but am running into problems. I think the problem is because I have two .ascx files that refer to the same .ascx.cs file. A simple example is like this... Ferret1.ascx =========
5
1517
by: pedestrian via DotNetMonster.com | last post by:
I'm just beginning to learn ASP.NET 2.0. I wonder what's the reason for using or not using the code behind file? Thanks for replying... -- Regards, Pedestrian, Penang. Message posted via DotNetMonster.com
0
9646
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10350
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...
0
10157
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10097
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
9957
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
7505
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
6742
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
5386
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...
2
3658
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.