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
394 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:mwmiller78
  • 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:mwmiller78
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:mwmiller78
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:
mwmiller78 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:mwmiller78
ID: 40461699
Figured it out
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now