Solved

Dropdownlist - VB2005

Posted on 2006-07-22
1
288 Views
Last Modified: 2008-03-10
How can I do this. When I select an item on Dropdownlist, I want it to display the item on a textbox. Does it has to postback all the time. I'm using Dropdowlist Task and selected Datasource for SQL database.

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click


        Me.TextBox1.Text = Me.DropDownList1.SelectedItem.Text


    End Sub
0
Comment
Question by:VBdotnet2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 9

Accepted Solution

by:
jonorossi earned 125 total points
ID: 17160792
You can use some JavaScript to set the value of the text box with the onchange html select event. Or you could use an AJAX framework like Microsoft Atlas (atlas.asp.net) if you are going to do more than just setting a basic value (eg. getting data from your database).

Here is some javascript that you can use. Take note that ASP.NET changes the names of your controls so you might like to make use of the ClientID property of your controls instead of hardcoding the IDs.

  <script type="text/javascript">
    function setTextBoxValue() {
      var ddl = document.getElementById("ddlTest");
      document.getElementById("txtTest").value = ddl.options[ddl.selectedIndex].value;
    }
  </script>
 
  <select id="ddlTest" onchange="javascript:setTextBoxValue();">
    <option>hey</option>
    <option>bye</option>
  </select>
 
  <input id="txtTest" type="text" />
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

695 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