我想要使​​用anchar标签绑定图像

我想要使​​用anchar标签绑定图像

本文介绍了我想要使​​用anchar标签绑定图像。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是编码。



This is coding.

 protected void MyRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            return;
        Object objImageLink = e.Item.FindControl("imageLink");
        Image imgHomeImage = (Image)e.Item.FindControl("imgHomeImage");
        Label lblImageName = (Label)e.Item.FindControl("lblImageName");


        if (objImageLink != null && imgHomeImage != null && lblImageName != null)

            imgHomeImage.ImageUrl = "~/Uploadfile/" + lblImageName.Text;
            HtmlAnchor anchor = objImageLink as HtmlAnchor;
            anchor.HRef = "~/Uploadfile/" + lblImageName.Text;
             anchor.DataBind();

            //imgHomeImage1. = "~/Uploadfile/" + lblImageName.Text;

        //string filepath = GetImagePath(Convert.ToString(resultTable.Rows[e.Item.ItemIndex]["ImageName"]));
        //// set anchor tag
        //Object objImageLink = e.Item.FindControl("imageLink");
        //if (objImageLink != null)
        //{
        //    HtmlAnchor anchor = objImageLink as HtmlAnchor;
        //    anchor.HRef = filepath;
        //    anchor.DataBind();
        //}
    }
}

推荐答案

<a hre="#"><img id="img_logo" style="height: 40px; width: 60px;" runat="server" /></a>


这篇关于我想要使​​用anchar标签绑定图像。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 19:50