Solved

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

Posted on 2008-06-17
1
487 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

911 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

23 Experts available now in Live!

Get 1:1 Help Now