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
438 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
  • 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
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…

821 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