473,396 Members | 1,998 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.

Question abt WebForm.

Dear all,

i hav a question.. i hav a dropdown list, with Apple, Banana, and Other
value in it.

What i wanna do is, when Other is selected, then 1 lable and 1 textbox
occured to let user to key in the Other value....

how can i achieve it..??

thanks and pls advice.

cheers,
CS
Nov 19 '05 #1
1 862
Wong CS wrote:
i hav a question.. i hav a dropdown list, with Apple, Banana, and Other
value in it.

What i wanna do is, when Other is selected, then 1 lable and 1 textbox
occured to let user to key in the Other value....

You can show and hide the Label and TextBox controls based on the
selection in the DropDownList. The following example (C#) show how this
can be done:
<%@ Page language="c#" AutoEventWireup="true" %>
<script runat="server">
void Page_Load()
{
}
void SelectedIndexChanged(object src, EventArgs e) {
if (((DropDownList)src).SelectedItem.Value=="Other") {
Label1.Visible=true;
TextBox1.Visible=true;
} else {
Label1.Visible=false;
TextBox1.Visible=false;
}
}
</script>
<html>
<body>
<form runat="server">
<asp:DropDownList AutoPostBack="true"
OnSelectedIndexChanged="SelectedIndexChanged" ID="DropDownList1"
Runat="server">
<asp:ListItem Value="Banana">Banana</asp:ListItem>
<asp:ListItem Value="Apple">Apple</asp:ListItem>
<asp:ListItem Value="Other">Other</asp:ListItem>
</asp:DropDownList>
<asp:Label Visible="false" ID="Label1" Runat="server" Text="Name
of fruit:"></asp:Label>
<asp:TextBox Visible="false" ID="TextBox1"
Runat="server"></asp:TextBox>
</form>
</body>
</html>

Anders Norås
http://dotnetjunkies.com/weblog/anoras/
Nov 19 '05 #2

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

Similar topics

1
by: G.Esmeijer | last post by:
Friends, working with C# ASP.NET Would like to startup my webform with http://myweb?Nr=1234?mg=1 What I want is: - bring 2 parameters to my webform (aspx) and use put these values in two...
2
by: Newbie | last post by:
I have a C# asp.net webform that contains a dropdownlist and a button that allows the user to select another item in the dropdownlist. The webform should work as follows: When the user selects...
2
by: VB Programmer | last post by:
I created a VB6 user control with a ActiveX Knob on it. Here's the simple code: Public Property Get Value() As Integer Value = CWKnob.Value End Property Public Property Let Value(Value As...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
3
by: VB Programmer | last post by:
My webform is datadriven and auto refreshes every 10 seconds. Is there a way to avoid the "flicker" when I refresh the page?
5
by: mg | last post by:
Is there a simple way to determine the name & path of the Web page that calls a WebForm when the calling page is another type such as an html, jsp, or .do file.
3
by: Harry | last post by:
Dear all, It is found that when a webform control trigger an event, Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub This...
5
by: John W | last post by:
Hello, I have been wondering that everytime I do a submit on a button/form (postback) it is using the same webform on the CS, how do I goto another webform once I have done a postback and...
1
by: adam | last post by:
I have a simple form question. I order to access a payment gateway I have a asp.net page which has to have a form that use POST for method and _blank for target. Before the information of the form...
5
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have start web form and when the user clicks a button (server.transfer) they are directed to the second webform. I was wondering if there is a way to create an instance of the first webform...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
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.