超链接图片 [英] Hyperlink image

查看:229
本文介绍了超链接图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些缩略图,我有一个中继器显示,使用超链接和图像控制。我希望能够点击缩略图,显示在同一页面上更大的图片,我想的imagename为URL的一部分。林真的坚持现在。我用查询字符串或..?结果
我的超级链接现在看起来是这样的:

 < ASP:超链接ID =超链接=服务器NavigateUrl ='<%#的eval(名,内容/图片/ {0}) %GT;'的ImageUrl ='<%#内容/缩略图/+的eval(姓名)%>' >超链接< / ASP:超链接>

修改
是的,路径是图像:〜/内容/图片/。
下面是一些我的code的背后,也许有助于解释我在做什么。

 保护无效的Page_Load(对象发件人,EventArgs的发送)
{
    字符串imgPath =使用Server.Mappath(〜/内容/图片/);
    清单<&的FileInfo GT;照片=新的List<&的FileInfo GT;();    DirectoryInfo的DirectoryInfo的=新DirectoryInfo的(imgPath);
    的FileInfo [] =的fileInfo directoryInfo.GetFiles();    的foreach(在FileInfo的的fileInfo文件)
    {
        images.Add(文件);
    }    FileRepeater.DataSource =图像;
    FileRepeater.DataBind();}保护无效UploadButton_Click(对象发件人,EventArgs的发送)
{    var文件= ChooseFileUpload.FileContent;
    字符串文件名= ChooseFileUpload.FileName;    变种SI = Gallery.SaveImage(文件,文件名);
 }


解决方案

是的......查询字符串应该是罚款......它可以像

内容/缩略图/ page.aspx?imageName =你的形象的名字

更新:

存储图像哪里......他们有一个独特的价值/身份?...如果是的话,而不是使用的东西一样网址

内容/缩略图/ page.aspx?imageid =你的形象标识

这应该是你的缩略图超链接的导航网址...,当用户点击缩略图......只是做一个查询/调用到哪里的图像存储与价值查询字符串的ID ... 。您可以通过现成的Request.QueryString查询字符串值[imageId]你的情况...

I have some thumbnails that I display with a Repeater, using a hyperlink and image control. I want to be able to click on a thumbnail, display the bigger image on the same page and I want the imagename to be part of the URL. Im really stuck right now. Do I use QueryString or..?
My hyperlink now looks like this:

<asp:HyperLink ID="HyperLink" runat="server"      NavigateUrl='<%#Eval("name","Content/Images/{0}") %>' ImageUrl='<%#"Content/Thumbnails/" + Eval("Name") %>' >HyperLink</asp:HyperLink>

Edit Yes, the path to the images is: ~/Content/Images/. Here's some of my code behind, maybe it helps to explain what I'm doing.

protected void Page_Load(object sender, EventArgs e)
{
    string imgPath = Server.MapPath("~/Content/Images/");
    List<FileInfo> images = new List<FileInfo>();

    DirectoryInfo directoryInfo = new DirectoryInfo(imgPath);
    FileInfo[] fileInfo = directoryInfo.GetFiles();

    foreach (FileInfo file in fileInfo)
    {
        images.Add(file);
    }

    FileRepeater.DataSource = images;
    FileRepeater.DataBind();

}

protected void UploadButton_Click(object sender, EventArgs e)
{

    var file = ChooseFileUpload.FileContent;
    string fileName = ChooseFileUpload.FileName;

    var si = Gallery.SaveImage(file, fileName);
 }

解决方案

Yes...QueryString should be fine...it can be something like

Content/Thumbnails/page.aspx?imageName="your image name"

Update:

Where are the images stored...do they have a unique value/identity?...if yes then instead use a url of something like

Content/Thumbnails/page.aspx?imageid="your image id"

this should be the navigate url of your thumbnail image hyperlinks... and when the user clicks on a thumbnail...just make a query/call to wherever the images are stored with the id value in the querystring....you can ready querystring value by Request.QueryString["imageId"] in your case...

这篇关于超链接图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆