Javascript 如何计数数据列表项(图像)
我想在javascript的数据列表中计算图片(ImageUploaded)中的项目,我如何才能做到这一点Javascript 如何计数数据列表项(图像),javascript,asp.net,datalist,Javascript,Asp.net,Datalist,我想在javascript的数据列表中计算图片(ImageUploaded)中的项目,我如何才能做到这一点 <asp:DataList ID="DataListUploadedPhotos" ClientIDMode="Static" runat="server" RepeatDirection="Horizontal" RepeatColumns="3" CellPadding="10" CellSpacing="10" OnItemDataBound="DataListUploade
<asp:DataList ID="DataListUploadedPhotos" ClientIDMode="Static" runat="server" RepeatDirection="Horizontal" RepeatColumns="3" CellPadding="10" CellSpacing="10" OnItemDataBound="DataListUploadedPhotos_ItemDataBound" ItemStyle-VerticalAlign="Top">
<ItemTemplate>
<table border="0" cellpadding="2" cellspacing="0" align="left" width="100%">
<tr> <td align="left" style="width:200px; height:30px">
<b>
<asp:Label ID="LabelImageTitle" runat="server" Text='<%#Eval("title")%>' Height="10px"></asp:Label>
</b> </td> <td align="right"> </td> </tr> <tr> <td align="center" colspan="2" style="background-color: #eeeeee; width: 260px; height: 260px" valign="middle">
<asp:Image ID="ImageUploaded" runat="server" ImageUrl='<%#"../upload/photos/LargeThumbs/"+Eval("fileName")%>'
AlternateText='<%#Eval("title")%>' ClientIDMode="Static" Style="border: 5px solid #eeeeee;" onclick='<%# "return ImageSelected(this.id, " + Eval("photoId") +",\"ContentPlaceHolder1_txtIds\");"%>' /></td>
</tr>
<tr>
<td>
<a href='<%#"../upload/photos/PopUpThumbs/"+Eval("fileName")%>'>
<asp:ImageButton ID="ImageButtonResultClose" runat="server" ImageUrl="~/images/enlarge.png" /> </a>
<asp:Label ID="LabelPhotoid" runat="server" Text='<%#Eval("photoId")%>'></asp:Label>
</td>
<td>
<asp:ImageButton ID="details" runat="server" ImageUrl="~/images/details.png" OnClick="details_Click"
CommandArgument='<%#Eval("photoId")%>'/>
</td></tr>
<tr>
<td>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
您需要对上载图像的文件夹中的项目进行计数 像这样的
string mydir = @"C:\images\";
string[] files;
int numberofFiles;
files = Directory.GetFiles(mydir);
numberofFiles = files.Length;
string nextFileName = (numberofFiles + 1).ToString() + ".jpg";
让我知道这是否有助于为您的图像提供一个类,例如
ClassName=“imgUploaded”
。如果您使用jQuery,那么img的计数将是$(“.imgUploaded”)。长度
基本上,我想在JavaScriptList中的每个图像控件(ImageUploaded)上应用边框宽度,然后您需要在问题中指定。你的问题缺乏具体细节。我建议你在我的论坛上提出另一个问题,并明确要求。根据问题回答是合适的