473,396 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DropDownChange

I'm trying to show and hide web controls based on ListItem value
selected. I thought that if I put the values of the ID's in the
ListItem it would make it easier to acces.

<script runat="server">

protected void DropDownList1_SelectedIndexChanged(object sender,
EventArgs e)
{

}
</script>

<%@ Register TagPrefix="ED" TagName="Directory" Src="employee.ascx" %>
<%@ Register TagPrefix="GN" TagName="Numbers"
Src="general_numbers.ascx" %>

<asp:Content ID="HeaderContent"
ContentPlaceHolderID="Header_Content" runat="server">

<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem value="boo">Employee Directory</
asp:ListItem>
<asp:ListItem value="moo">General Numbers</
asp:ListItem>
</asp:DropDownList>

<ED:Directory ID="boo" runat="server" Visible=true/
>
<GN:Numbers ID="moo" runat="server" Visible=false/
>
</asp:Content>

Feb 19 '07 #1
2 1042
On Feb 20, 12:05 am, vnc...@hotmail.com wrote:
I'm trying to show and hide web controls based on ListItem value
selected. I thought that if I put the values of the ID's in the
ListItem it would make it easier to acces.

<script runat="server">

protected void DropDownList1_SelectedIndexChanged(object sender,
EventArgs e)
{

}
</script>

<%@ Register TagPrefix="ED" TagName="Directory" Src="employee.ascx" %>
<%@ Register TagPrefix="GN" TagName="Numbers"
Src="general_numbers.ascx" %>

<asp:Content ID="HeaderContent"
ContentPlaceHolderID="Header_Content" runat="server">

<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem value="boo">Employee Directory</
asp:ListItem>
<asp:ListItem value="moo">General Numbers</
asp:ListItem>
</asp:DropDownList>

<ED:Directory ID="boo" runat="server" Visible=true/

<GN:Numbers ID="moo" runat="server" Visible=false/

</asp:Content>
what is the problem?

Feb 19 '07 #2
Howdy,

First, make sure AutoPostBack propertu is set to true:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true">
<asp:ListItem Value="boo" Text="Employee Directory"/>
<asp:ListItem Value="moo" Text="General Numbers"/>
</asp:DropDownList>

then amend the code:
<script runat="server">

protected void DropDownList1_SelectedIndexChanged(object sender,
EventArgs e)
{
DropDownList dropDownList = (DropDownList) sender;

string value = dropDownList.SelectedValue;

boo.Visible = (value == "boo");
moo.Visible = (value == "moo");
}
</script>

Is that what you want?

--
Milosz
"vn****@hotmail.com" wrote:
I'm trying to show and hide web controls based on ListItem value
selected. I thought that if I put the values of the ID's in the
ListItem it would make it easier to acces.

<script runat="server">

protected void DropDownList1_SelectedIndexChanged(object sender,
EventArgs e)
{

}
</script>

<%@ Register TagPrefix="ED" TagName="Directory" Src="employee.ascx" %>
<%@ Register TagPrefix="GN" TagName="Numbers"
Src="general_numbers.ascx" %>

<asp:Content ID="HeaderContent"
ContentPlaceHolderID="Header_Content" runat="server">

<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem value="boo">Employee Directory</
asp:ListItem>
<asp:ListItem value="moo">General Numbers</
asp:ListItem>
</asp:DropDownList>

<ED:Directory ID="boo" runat="server" Visible=true/
<GN:Numbers ID="moo" runat="server" Visible=false/

</asp:Content>

Feb 19 '07 #3

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

Similar topics

2
by: Steven | last post by:
This one should be a fairly simple one for you guys. I want to create a small dropDown list (custom control) and when the user selects anyone of the value, the control should pass back the Selected...
4
by: James | last post by:
Basically I have a DataGrid that I'm binding to the results of a stored procedure call. The recordset is fairly small. Initially I'm creating a DataSet from the results and binding it. There's a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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
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
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...
0
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,...

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.