Solved

Populate textbox from dropdown control selection asp.net visual studio 2008

Posted on 2008-06-17
1
484 Views
Last Modified: 2013-11-26
I have a dropdown control with a number of options in asp.net page

If I select an option from the dropdown list I want to the selected text of the dropdown to be appended to a multi line textbox on the same form.

If I select another option from the dropdown control I want that selected text to also be appended to the textbox.  So the end result would be a multi line text box populated with say upto 6 lines.

I need a quick over view demo not a link to another site

Thanks

0
Comment
Question by:mugsey
1 Comment
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
ID: 21800689
A very easy example
ASPX-file

---------

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
 

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>Untitled Page</title>

</head>

<body>

    <form id="form1" runat="server">

    <asp:DropDownList ID="DropDownList1" runat="server" 

        onselectedindexchanged="DropDownList1_SelectedIndexChanged" 

        AutoPostBack="True">

        <asp:ListItem>Item1</asp:ListItem>

        <asp:ListItem>Item2</asp:ListItem>

        <asp:ListItem Value="Item3"></asp:ListItem>

        <asp:ListItem>Item4</asp:ListItem>

        <asp:ListItem>Item5</asp:ListItem>

        <asp:ListItem>Item6</asp:ListItem>

        <asp:ListItem>Item7</asp:ListItem>

    </asp:DropDownList>

    <p>

    <asp:TextBox ID="TextBox1" runat="server" Height="141px" Rows="6" 

            TextMode="MultiLine"></asp:TextBox>

    </p>

    </form>

</body>

</html>
 
 

ASPX.CS-file

------------

using System;

using System.Configuration;

using System.Data;

using System.Linq;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.HtmlControls;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;
 

public partial class _Default : System.Web.UI.Page 

{

    protected void Page_Load(object sender, EventArgs e)

    {
 
 
 

        if (!Page.IsPostBack)

        {

        }
 

    }
 

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)

    {

        TextBox1.Text += DropDownList1.SelectedValue + System.Environment.NewLine;

    }

    
 

}

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now