?
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
Medium Priority
?
493 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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?
This article discusses how to implement server side field validation and display customized error messages to the client.
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

765 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