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
465 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 12

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 12

Expert Comment

by:jitendra patil
ID: 40444128
can you share your javascript code here?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 12

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
Suggested Courses

732 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