|
|
|
 |
 |
Исходник |
 |
|
 |
 |
|
Автор:
|
|
|
Название:
|
Фотоальбом он-лайн (XML version) |
|
Дата:
|
28 December 2006 |
|
Описание: |
Фотоальбом он-лайн. Основные достоинства - автоматическое обновление содержимого папки с фотографиями (достаточно одной таблэтки... шутю... достаточно загрузить фото в нужную папку). Есть предпросмотр. Код с реальной страницы, так что есть немного лишнего... Работающий пример здесь http://www.renthai.com/pictures.aspx |
| |
Разместить ссылку на этот исходник в форуме вы можете вставив в текст сообщения
следующую строку:
[CODEPOST ID=201]Фотоальбом он-лайн (XML version)[/CODEPOST] |
| Оценка: |
Проголосовало 10 посетителей, средняя оценка 2.30 |
| Оценить: |
|
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Collections.Specialized" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace = "System.Xml" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Reading directories
Dim directoryList As String()
directoryList = Directory.GetDirectories(Server.MapPath(".") & "\photo\")
'Finding names of the folders
Dim myFolders As String
Dim folderName As String
Dim found As New NameValueCollection
For Each myFolders In directoryList
folderName = myFolders.Substring(myFolders.LastIndexOf("\") + 1)
found.Add(folderName, "1") 'Adding folders names to Collection
Next
'Binding names of the folders to DDL
If Not Page.IsPostBack Then
ddlCategories.DataSource = found
ddlCategories.DataBind()
End If
lblCategories.Text = "Выберите категорию для просмотра"
End Sub
Protected Sub gvPictures_SelectedIndexChanging(ByVal sender As Object, ByVal e As GridViewSelectEventArgs)
'reading path to selected picture
Dim url As String
Dim row As GridViewRow = gvPictures.Rows(e.NewSelectedIndex)
url = row.Cells(2).Text
bigImg.ImageUrl = url
End Sub
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
'Looking for the files in the directory that is Value of DropDownList
Dim imageRoot As String()
imageRoot = Directory.GetFiles(Server.MapPath(".") & "\photo\" & ddlCategories.SelectedItem.Value & "\")
're-writing directorie content into XML
Dim url As String
Dim xw As New XmlTextWriter(Server.MapPath("pics.xml"), Encoding.UTF8)
With xw
.WriteStartDocument()
.WriteStartElement("photo")
For Each url In imageRoot
.WriteStartElement("pics", Nothing)
.WriteAttributeString("url", "photo\" & ddlCategories.SelectedItem.Value & "\" & url.Substring(url.LastIndexOf("\") + 1))
.WriteEndElement()
Next
.WriteEndElement()
End With
xw.Flush()
xw.Close()
Response.Redirect("pictures.aspx")
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Аренда недвижимости в Бангкоке</title>
<META content="аренда недвижимость вилла дом кондоминиум кондо таунхаус" name=keywords>
<META content="аренда недвижимости в Таиланде, аренда кондоминиума, аренда дома, аренда виллы" name=description>
<link type="text/css" rel="Stylesheet" href="default.css" />
<script language="javascript" type="text/javascript" src="navigator.js">
</script>
</head>
<body>
<h1 class="page_name">Фотоальбом</h1>
<div id="logo">
<img src="images/rtlogo.gif" />
</div>
<div id="side_menu">
<!-- #INCLUDE FILE="side_menu.inc" -->
</div>
<div id="up_links">
<!-- #INCLUDE FILE="up_links.inc"-->
</div>
<form id="form1" runat="server">
<div id="side_pic">
<asp:Label runat="server" ID="lblCategories" Font-Names="Verdana" Font-Size="XX-Small" ForeColor="SteelBlue"></asp:Label>
<br />
<asp:DropDownList runat="server" ID="ddlCategories" >
</asp:DropDownList>
<asp:LinkButton ID="LinkButton1" runat="server" Font-Names="Verdana" OnClick="LinkButton1_Click">Выбрать</asp:LinkButton></div>
<asp:SiteMapPath ID="map" runat="server">
</asp:SiteMapPath>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/pics.xml"></asp:XmlDataSource>
<asp:Image ID="bigImg" runat="server" />
<asp:GridView ID="gvPictures" runat="server" AllowPaging="True" AutoGenerateColumns="False"
DataSourceID="XmlDataSource1" BorderStyle="Solid" BorderWidth="0px" PageSize="5" onselectedindexchanging="gvPictures_SelectedIndexChanging" >
<Columns>
<asp:CommandField ShowSelectButton="True" ButtonType="Image" SelectImageUrl="~/images/loop.gif" SelectText="Увеличить" />
<asp:ImageField DataImageUrlField="url" ShowHeader="False">
<ControlStyle Width="100px" />
</asp:ImageField>
<asp:BoundField DataField="url" SortExpression="url" ShowHeader="False">
<ControlStyle Font-Size="1px" ForeColor="White" Width="1px" />
<ItemStyle Font-Size="1px" ForeColor="White" Width="1px" />
<HeaderStyle Width="1px" />
</asp:BoundField>
</Columns>
</asp:GridView>
</form>
</body>
</html> |
| Вернуться к списку исходников в категории Общие вопросы программирования на ASP.NET |
|
|
 |
 |
 |
 |
|
|