我试图获取放置在转发器中的下拉列表的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);
}
用户界面实施
<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>
答案 0 :(得分:1)
在你的JS ajax函数中,
var oObject= document.getElementById('colorList1');
var id = oObject.id;