nazdar,
nedávno som sa začal trochu zaujímať o C# v .NET a skúšam robiť jednoduchú webstránku, no mám menší problém s fotogalériou:
súbor Fotky.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
public partial class Account_Fotky : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
UploadImage();
}
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
string fileName = Guid.NewGuid().ToString();
FileUpload1.PostedFile.SaveAs(Server.MapPath("~/images/fotky/" + fileName + ".png"));
}
Response.Redirect("~/Account/Fotky.aspx");
}
public void UploadImage()
{
foreach (string strFileName in Directory.GetFiles(Server.MapPath("~/images/fotky/")))
{
ImageButton imageButton = new ImageButton();
FileInfo fileInfo = new FileInfo(strFileName);
imageButton.ImageUrl = "~/images/fotky/" + fileInfo.Name;
imageButton.Width = Unit.Pixel(150);
imageButton.Height = Unit.Pixel(100);
imageButton.Style.Add("padding", "5px");
imageButton.Click += new ImageClickEventHandler(imageButton_Click);
ListView1.Controls.Add(imageButton);
}
}
void imageButton_Click(object sender, ImageClickEventArgs e)
{
Image2.ImageUrl = ((ImageButton)sender).ImageUrl;
}
}
Fotky.aspx
<%@ Page Title="Fotky" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="Fotky.aspx.cs" Inherits="Account_Fotky" %>
<%@ Register Src="~/Account/OpenAuthProviders.ascx" TagPrefix="uc" TagName="OpenAuthProviders" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script src="/Scripts/script.js"></script>
<div class="row1" style="border-radius:0; position:relative; z-index:3;overflow: hidden;" >
<h2 style="margin-left: 23px; position:relative; z-index:4;overflow: hidden;">Fotky</h2>
<center>
<hr style="border: 1px solid #555; margin-left:23px; margin-right:23px;position:relative; z-index:4;overflow: hidden;" />
<div id="slideshow" style=" position:relative; z-index:4;overflow: hidden;">
<ul style="slide">
<li><asp:Image ID="Image2" runat="server" Width="100%" ></asp:Image></li>
</ul>
<span class="arrow previous"></span>
<span class="arrow next"></span>
</div><br />
<div style="margin-left: 23px; padding-bottom:-10px; position:relative; z-index:4;overflow: hidden; width: 60%;">
<asp:ListView ID="ListView1" runat="server">
</asp:ListView>
<asp:FileUpload ID="FileUpload1" runat="server" />
<div class="col-md-offset-2 col-md-10" style="margin-top:0px; margin-left:130px;"> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Upload" CssClass="btn btn-default"/></div>
</div>
</center><br /><br />
<div style="background-color:#FFFFFF; opacity:0.7; width:100%;height:100%;position: absolute; z-index:1;margin-top:-1201px;">
</div>
</div>
</asp:Content>
Mám spravené že keď kliknem na nejaký obrázok v tom ListViewe že sa mi zobrazí v tom hornom okne a chcel by som spraviť aby sa dalo v tom okne meniť tými šípkami fotky z toho listViewu.
Neviete mi poradiť ako by sa to dalo spraviť ?
kľudne opravte aj nejaké chyby v mojom kóde
vopred ďakujem