Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

trouble with asp.net Image

Avatar of Nate_LR
Nate_LR asked on
1 Comment1 Solution229 ViewsLast Modified:
I'm attempting to select an image path from a database and  load it into an asp Image, but the image doesn't show.
<asp:FormView ID="FormView1" runat="server"  DataSourceID="SqlDataSource1" Width="100%" >
            <table style="width: 100%">
                        <asp:Image ID="Image1" runat="server" Width="1000px" ImageUrl='FieldPics/<%# Eval("relPath") %>' />
                        <%--<img src='FieldPics/<%# Eval("relPath") %>' width="1000px" id="Image1" alt="myPic" />--%>
                        <asp:Label ID="Label1" runat="server" Font-Bold="True" Text='<%# Eval("photoBy") %>' Font-Names="Verdana" Font-Size="12px"></asp:Label>
                        <asp:Button ID="btnRotLeft" runat="server" Text="Rotate Left" />
                        <asp:Button ID="btnRotRight" runat="server" Text="Rotate Right" OnClick="btnRotRight_Click" />

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        SelectCommand="SELECT replace(relPath,'\', '/') as relPath, picDateTime, county, quad, photoBy, photoDesc, fTrackID FROM fieldPics WHERE id = @PhotoID">
            <asp:QueryStringParameter Name="PhotoID" QueryStringField="photoid" Type="Int32" />

If I do this with an html image, it will show...
<img src='FieldPics/<%# Eval("relPath") %>' width="1000px" id="Image1" alt="myPic" />

But I'm trying to rotate the image with ImageMagick and then I can't do this....
protected void btnRotRight_Click(object sender, EventArgs e)
        Image img = (Image)FormView1.FindControl("Image1");
        string imgSrc = img.ImageUrl;
        ClientScript.RegisterStartupScript(this.GetType(), "error", string.Format("alert('{0}');", imgSrc), true);
        string arg = @"convert """ + Server.MapPath(imgSrc) + @""" -rotate 90 """ + Server.MapPath(imgSrc) + @"""";
        displayImg(imgSrc, 5000);

I also can't get a proper ImageUrl into my ImageMagick command.  It tells me I have illegal characters.  When I use window.alert to display the ImageUrl it shows 'FieldPics/<%# Eval("relPath") %>' rather than 'FieldPics/CONWAY/ATKINS/DSCN0220.JPG'
Avatar of Nate_LR

Our community of experts have been thoroughly vetted for their expertise and industry experience.

This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answers