Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/74.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ASP.NET获取放置在中继器内部的dropdownlist的id_Javascript_Jquery_Asp.net_Ajax_Repeater - Fatal编程技术网

Javascript ASP.NET获取放置在中继器内部的dropdownlist的id

Javascript ASP.NET获取放置在中继器内部的dropdownlist的id,javascript,jquery,asp.net,ajax,repeater,Javascript,Jquery,Asp.net,Ajax,Repeater,我正在尝试获取放置在中继器中的dropdownlist的id,以便进行一些ajax调用,但我做不到。我如何使之成为可能我的实施如下: Ajax函数 function ShowCurrentTime() { $.ajax({ type: "POST", url: "WebForm1.aspx/showColor", data: '{name: "' + $("#<%=colorList1.ClientID%>").val() +

我正在尝试获取放置在中继器中的dropdownlist的id,以便进行一些ajax调用,但我做不到。我如何使之成为可能我的实施如下:

Ajax函数

function ShowCurrentTime() {
    $.ajax({
        type: "POST",
        url: "WebForm1.aspx/showColor",
        data: '{name: "' + $("#<%=colorList1.ClientID%>").val() + '" }',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: OnSuccess,
        failure: function (response) {
            alert(response.d);
        }
    });
}
function OnSuccess(response) {
    alert(response.d);
}
函数ShowCurrentTime(){
$.ajax({
类型:“POST”,
url:“WebForm1.aspx/showColor”,
数据:“{name:”+$(“#”).val()+“}”,
contentType:“应用程序/json;字符集=utf-8”,
数据类型:“json”,
成功:一旦成功,
故障:功能(响应){
警报(response.d);
}
});
}
函数OnSuccess(响应){
警报(response.d);
}
用户界面实现

<ajaxToolkit:TabPanel ID="TabPanel5" runat="server">
                <HeaderTemplate>Show Shoes</HeaderTemplate>
                <ContentTemplate runat="server">
                    <input id="btnGetTime" type="button" value="Show Current Time" onclick = "al()" />                                        
                    <asp:Repeater ID="shoeRepeater" OnItemCreated="shoeRepeater_ItemCreated" runat="server">
                        <HeaderTemplate></HeaderTemplate>
                        <ItemTemplate>

                            <table border="1" style="border-color:#ff9900; width:400px; font-weight:bold; font-family:'Oswald', Arial, sans-serif;">
                                <tr>
                                    <td rowspan="6" style="width:150px; height:150px;">
                                        <image src="shoeImages/<%#DataBinder.Eval(Container.DataItem,"ImagePath") %>"></image>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <%#DataBinder.Eval(Container.DataItem,"BrandName") %> <%#DataBinder.Eval(Container.DataItem,"ModelName") %> 
                                    </td>

                                </tr>
                                <tr>
                                    <td>
                                        Price: $<%#DataBinder.Eval(Container.DataItem,"Price") %>
                                    </td>

                                </tr>
                                <tr>
                                    <td>
                                        Size: <%#DataBinder.Eval(Container.DataItem,"Size") %>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <asp:DropDownList ID="colorList1" runat="server">
                                            <asp:ListItem>asdas</asp:ListItem>
                                            <asp:ListItem>asf</asp:ListItem>
                                        </asp:DropDownList>
                                        Color: <%#DataBinder.Eval(Container.DataItem,"PrimaryColor") %> - <%#DataBinder.Eval(Container.DataItem,"SecondaryColor") %>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        Quantity: <%#DataBinder.Eval(Container.DataItem,"Quantity") %>
                                    </td>

                                </tr>
                            </table>
                        </ItemTemplate>
                        <FooterTemplate></FooterTemplate>
                    </asp:Repeater>
                </ContentTemplate>
            </ajaxToolkit:TabPanel>

展示鞋
价格:$
尺寸:
阿斯达斯
asf
颜色:-
数量:

在JS ajax函数中

 var oObject= document.getElementById('colorList1');
 var id = oObject.id;

在我获得id后,如何从dropdownlist中获取所选选项的值?将jS事件连接到下拉列表,函数ddl(ddl){alert(ddl.value);},试试看!asp没有改变的方法:DropDownList,对不起,我一定是在做梦,不用担心,我们有时都会这么做,欢迎!