Solved

Making a selection from an AJAX dropdown extender appear in a textbox inside a repeater in ASP.NET / Javascript

Posted on 2014-11-11
7
476 Views
Last Modified: 2014-11-24
I'm trying to make an AJAX dropdownextender selection (from a list box) that is inside a repeater control, populate the relative text box when a selection is made.

<asp:TextBox ID="tbSeparator" Text=<%#Eval("Separator")%> runat="server" Wrap="False" Width="176" Font-Names="Verdana" ForeColor="#666666"></asp:TextBox>
   <cc1:DropDownExtender ID="ddeSeparator" DropDownControlID="lbSeparator"
        runat="server" DynamicServicePath="" Enabled="True" TargetControlID="tbSeparator"
        HighlightBackColor="WhiteSmoke">
    </cc1:DropDownExtender>
        <asp:ListBox ID="lbSeparator" runat="server"
        CssClass="alwaysontop" OnTextChanged="UpdateSeparator" Height="85px">
</asp:ListBox>

Open in new window


How do I do this?
TIA
0
Comment
Question by:Mike Miller
[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
  • 4
  • 3
7 Comments
 
LVL 13

Expert Comment

by:jitendra patil
ID: 40439297
try the below link code it displays the correct usage of dropdown extender
AJAX Control Toolkit Dropdown Extender Tutorial ASP.NET C#

here's another one
How to use DropDownExtender in asp.net ajax


hope this helps.
0
 

Author Comment

by:Mike Miller
ID: 40439996
Thanks. I'm able to utilize the dropdown extender, no problem. It's when it's inside a repeater is when I'm running into problems. Also, your links show how to make this happen in the code behind. Per my title, I'm trying to do this on the client side. Thanks again.
0
 
LVL 13

Expert Comment

by:jitendra patil
ID: 40444128
can you share your javascript code here?
0
What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

 

Author Comment

by:Mike Miller
ID: 40446035
<script type="text/javascript">
    function closest(ele, className) {
        do {
            ele = ele.parentNode;
            if (ele.className !== undefined && ele.className.indexOf(className) > -1) {
                return ele;
            }
        } while (ele.className !== undefined);
        return null;
    }
    	window.popit = function popit(ele) {
        var de = closest(ele.parentElement, 'entrye');
	de.getElementById("tbSeparator").innerHTML = this.options[this.selectedIndex].text;
    }
</script>

Open in new window


This is one of may variations I've been trying
0
 

Accepted Solution

by:
Mike Miller earned 0 total points
ID: 40453757
Ok got this one figured out. Here is my JS:

<script type="text/javascript">
    function closest(sep, className) {
        do {
            sep = sep.parentNode;
            if (sep.className !== undefined && sep.className.indexOf(className) > -1) {
                return sep;
            }
        } while (sep.className !== undefined);
        return null;
    }
    window.populate_sep = function populate_sep(sep) {
        var dms = closest(sep.parentElement, 'entry');
        dms.getElementsByClassName("tbSeparator")[0].value = sep.options[sep.selectedIndex].text;
    }
</script>

Open in new window


And I had to change some of the HTML...
(Inside the repeater)
<asp:TextBox ID="tbSeparator" Text=<%#Eval("Separator")%> runat="server" Wrap="False" Width="176" Font-Names="Verdana" ForeColor="#666666" Class="tbSeparator" Name="tbSeparator"></asp:TextBox>
   <cc1:DropDownExtender ID="ddeSeparator" DropDownControlID="lbSeparator"
        runat="server" DynamicServicePath="" Enabled="True" TargetControlID="tbSeparator"
        HighlightBackColor="WhiteSmoke">
    </cc1:DropDownExtender>
        <asp:ListBox ID="lbSeparator" runat="server" Class="lbSeparator" Name="lbSeparator"
        CssClass="alwaysontop" Height="85px" onclick="populate_sep(this)">
</asp:ListBox>

Open in new window

0
 
LVL 13

Expert Comment

by:jitendra patil
ID: 40454400
glad to know you got the solution,
sorry for the delay,  couldn't get back to you.
0
 

Author Closing Comment

by:Mike Miller
ID: 40461699
Figured it out
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

705 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