Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 10th, 2008, 04:25 AM
Authorized User
Join Date: Nov 2007
Location: Allahabad, UP, India.
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default How can I set TextBox value from asp.net Listbox,

How can I set TextBox value from asp.net Listbox, because I popuplate asp.net Listbox through java script..
I tried it by calling the java script function onChange(and onSelectedIndexChange) event of list box, but event is not calling java script function

from here..

following is my code--

<div id="helptypediv" style="visibility: hidden; z-index:1">
                            <asp:ListBox ID="lstShowHistory" SelectionMode="Single" runat="server" Width="200px" Height="300px"


function setTextBoxValue(e)
            //var strListBoxName = document.getElementById('lstShowHistory');
            document.getElementById('txtUrlLink').value = e ; //strListBoxName.options[strListBoxName.selectedIndex].text ;

//;options[document.getElementById('lstShowHistory').selected Index].text;

the list box is popuplate on mouse over event on the text box...

txtUrlLink.Attributes.Add("onfocus", "ShowList();");

function ShowList()
   document.getElementById('helptypediv').style.visib ility='visible';return false;

function getCookie()
        var strListBox = document.getElementById('lstShowHistory');
        var ls1= document.cookie.split("=");
        if (ls1.length >1)
            var ls2 = ls1[1].split("|");
            var count = ls2.length;
            var strLink = "";
            var optionItem;

            //Clear the previous options from the list
            for(var lstCount = strListBox.options.length-1; lstCount>-1; lstCount--)
                strListBox.options[lstCount] = null;
            if(count >= 2 )
                for(var x = count-1; x>=0; x--)
                        var ls3=ls2[x];//[x].split("|");
                        strLink+= ls3;
                        optionItem = new Option(ls3, ls3, false, false);
                        strListBox.options[strListBox.length] = optionItem;

  #2 (permalink)  
Old March 10th, 2008, 06:11 AM
Authorized User
Join Date: Nov 2007
Location: Allahabad, UP, India.
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts

g is my code--
I have resolved my problem..

following is code..
in CS file i added this line ..
lstShowHistory.Attributes.Add("onchange", "ShowText();");

and by javascript I set the value of textbox, but it works only on by selecting item from mouse.
How can I select value from the listbox by arrow key of keyboard?? Have you any idea...
function ShowText()
    var txtMessage =

document.getElementById('lstShowHistory').options[document.getElementById('lstShowHistory').selected Index].text;//GetComboText(document.g

    document.getElementById('txtUrlLink').value = txtMessage;
    document.getElementById('helptypediv').style.visib ility='hidden';return false;

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
SOS!How to realize multi-column asp.net ListBox? xewei VS.NET 2002/2003 2 June 3rd, 2007 09:24 PM
how to add scroll bars in asp.net listbox control DARSIN General .NET 3 January 26th, 2006 11:39 PM
Listbox/textbox johnjohn Classic ASP Basics 4 December 11th, 2004 12:14 AM
bag in vb.net,set enable for textBox q8z Beginning VB 6 0 October 21st, 2004 04:08 AM
Listbox to textbox Freddyfred Access VBA 2 May 10th, 2004 10:37 PM

All times are GMT -4. The time now is 06:12 AM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.