扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:廖煜嵘编译 来源:天极网 2007年11月8日
关键字: Windows
Sub Page_Load(sender as Object, e as EventArgs) ... ' Dim imgIndex as Integer = 0 If Not Request.QueryString("N") is Nothing AndAlso _ IsNumeric(Request.QueryString("N")) then imgIndex = CInt(Request.QueryString("N")) End If currentImgTitle.Text = "You are Viewing: " & _ Path.GetFileNameWithoutExtension(images(imgIndex).Name) & _ " (" & imgIndex + 1 & " of " & images.Length & ")" currentImg.ImageUrl = Path.GetFileName(images(imgIndex).Name) ... End Sub |
<asp:Label runat="server" id="currentImgTitle" /><br /> <asp:Image runat="server" id="currentImg" /> |
Sub Page_Load(sender as Object, e as EventArgs) ... If imgIndex > 0 then lnkPrev.NavigateUrl = "Default.aspx?N=" & imgIndex - 1 End If If imgIndex < images.Length - 1 then lnkNext.NavigateUrl = "Default.aspx?N=" & imgIndex + 1 End If ... End Sub |
<asp:HyperLink runat="server" id="lnkPrev" Text="< Previous" /> | <asp:HyperLink runat="server" id="lnkNext" Text="Next >" /> |
Sub Page_Load(sender as Object, e as EventArgs) ... dlIndex.DataSource = images dlIndex.DataBind() End Sub Sub dlIndex_ItemDataBound(sender as Object, e as DataListItemEventArgs) If e.Item.ItemType = ListItemType.Item OrElse _ e.Item.ItemType = ListItemType.AlternatingItem then 'Get the Hyperlink Dim hl as HyperLink = CType(e.Item.FindControl("lnkPic"), HyperLink) 'Set the Text and Navigation properties hl.Text = Path.GetFileNameWithoutExtension(_ DataBinder.Eval(e.Item.DataItem, "Name").ToString()) & _ " (" & _ Int(DataBinder.Eval(e.Item.DataItem, "Length") / 1000) & _ " KB)" hl.NavigateUrl = "Default.aspx?N=" & e.Item.ItemIndex End If End Sub |
<asp:DataList runat="server" id="dlIndex" OnItemDataBound="dlIndex_ItemDataBound" RepeatColumns="3"> <ItemTemplate> <li><asp:HyperLink runat="server" id="lnkPic" /></li> </ItemTemplate> </asp:DataList> |
<%@ Import Namespace="System.IO" %> <script runat="server" language="VB"> Sub Page_Load(sender as Object, e as EventArgs) Dim dirInfo as New DirectoryInfo(Server.MapPath("")) Dim images() as FileInfo = FilterForImages(dirInfo.GetFiles()) Dim imgIndex as Integer = 0 If Not Request.QueryString("N") is Nothing AndAlso IsNumeric(Request.QueryString("N")) then imgIndex = CInt(Request.QueryString("N")) End If currentImgTitle.Text = "You are Viewing: " & _ Path.GetFileNameWithoutExtension(images(imgIndex).Name) & _ " (" & imgIndex + 1 & " of " & images.Length & ")" currentImg.ImageUrl = Path.GetFileName(images(imgIndex).Name) If imgIndex > 0 then lnkPrev.NavigateUrl = "Default.aspx?N=" & imgIndex - 1 End If If imgIndex < images.Length - 1 then lnkNext.NavigateUrl = "Default.aspx?N=" & imgIndex + 1 End If dlIndex.DataSource = images dlIndex.DataBind() End Sub Function FilterForImages(images() as FileInfo) as FileInfo() Dim newImages as New ArrayList(images.Length) Dim i as Integer For i = 0 to images.Length - 1 If Path.GetExtension(images(i).Name) = ".jpg" OrElse _ Path.GetExtension(images(i).Name) = ".jpeg" OrElse _ Path.GetExtension(images(i).Name) = ".png" OrElse _ Path.GetExtension(images(i).Name) = ".gif" then newImages.Add(images(i)) End If Next Return CType(newImages.ToArray(GetType(FileInfo)), FileInfo()) End Function Sub dlIndex_ItemDataBound(sender as Object, e as DataListItemEventArgs) If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem then Dim hl as HyperLink = CType(e.Item.FindControl("lnkPic"), HyperLink) hl.Text = Path.GetFileNameWithoutExtension(DataBinder.Eval(e.Item.DataItem, "Name").ToString()) & _ " (" & Int(DataBinder.Eval(e.Item.DataItem, "Length") / 1000) & " KB)" hl.NavigateUrl = "Default.aspx?N=" & e.Item.ItemIndex End If End Sub </script> <HTML> <HEAD> <STYLE TYPE="text/css"> body { font-family:Verdana;font-size: medium;} .ImageTitle { font-weight:bold; font-size:large;} .index {font-size: small;} .NavLink { background-color: yellow; font-weight: bold; } </STYLE> </HEAD> <BODY> <center> <asp:Label runat="server" id="currentImgTitle" CssClass="ImageTitle" /><br /> <asp:Image runat="server" id="currentImg" /> <asp:HyperLink runat="server" CssClass="NavLink" id="lnkPrev" Text="< Previous" /> | <asp:HyperLink runat="server" CssClass="NavLink" id="lnkNext" Text="Next >" /> <asp:DataList runat="server" id="dlIndex" OnItemDataBound="dlIndex_ItemDataBound" RepeatColumns="3" CssClass="index"> <ItemTemplate> <li><asp:HyperLink runat="server" id="lnkPic" /></li> </ItemTemplate> </asp:DataList> </center> </BODY> </HTML> |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者