本文介绍了图片在javascript加载时不可见....的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,



以下是我在datalist中显示的图像代码。但是每当点击图像时,一些图像路径就会被破坏而不可见。



Hello All,

Below is my code for image to be shown in datalist. But whenever the image is clicked some images path are broken and not visible.

<asp:DataList runat="server" ID="dataimg" RepeatColumns="4" RepeatDirection="Horizontal"

                             ItemStyle-CssClass="panel" CssClass="table">
                            <ItemTemplate>
                                <li class="list-group-item list-group" style="width: 200px">
                                    <a href='<%# String.Concat("Img/",Eval("image")) %>' class="fancybox"

                                        target="_blank" title='<%#Eval("detail") %>' data-fancybox-group="testgroup">
                                        <img src='Img/<%#Eval("image") %>' alt="image" width="160px" height="160px" />
                                    </a>
                                    <asp:Label ID="Label1" runat="server" CssClass="text text-default" Font-Size="12px" Text='<%#Eval("detail") %>'></asp:Label>
                                    <%--<label id="label">
                                    <a href="<%#"design.aspx?pid="+Eval("ID") %>">View Details</a></label>--%>
                                </li>
                            </ItemTemplate>
                        </asp:DataList>





以下是我的C#代码: -





Below is my C# code:-

 protected void Unnamed1_Click(object sender, EventArgs e)
    {
        // NB: The "as" operator can return null:
        LinkButton lnk = sender as LinkButton;
        if (lnk == null)
        {
            throw new InvalidOperationException("sender is not a LinkButton!");
        }

        DateTime theDate;
        // NB: If your date is in a specific format, use TryParseExact instead.
        string format = "yyyy-MM-dd";
        if (!DateTime.TryParseExact(lnk.Text, format, null, DateTimeStyles.None, out theDate))
        {
            // The text is not a valid date:
            throw new FormatException(string.Format("The value '{0}' is not a valid date.", lnk.Text));
        }

        TextBox1.Text = lnk.Text;

        using (SqlConnection con1 = new SqlConnection(ConfigurationManager.AppSettings["str"]))
        using (SqlCommand cmd = new SqlCommand("SELECT * FROM date1 WHERE ddate = @ddate", con1))
        {
            cmd.Parameters.AddWithValue("@ddate", theDate.Date);

            DataSet ds1 = new DataSet();
            SqlDataAdapter da1 = new SqlDataAdapter(cmd);
            da1.Fill(ds1);

            dataimg.Visible = true;
            dataimg.DataSource = ds1;
            dataimg.DataBind();
        }
    }

Please HELP!!

推荐答案


这篇关于图片在javascript加载时不可见....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-31 18:11