?
Solved

trouble with asp.net Image

Posted on 2014-08-11
1
Medium Priority
?
189 Views
Last Modified: 2014-08-11
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%" >
        <ItemTemplate>
            <table style="width: 100%">
                <tr>
                    <td>
                        
                        <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>
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Button ID="btnRotLeft" runat="server" Text="Rotate Left" />
                        <asp:Button ID="btnRotRight" runat="server" Text="Rotate Right" OnClick="btnRotRight_Click" />
                    </td>
                </tr>                
            </table>
        </ItemTemplate>
    </asp:FormView>



    <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">
        <SelectParameters>
            <asp:QueryStringParameter Name="PhotoID" QueryStringField="photoid" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>

Open in new window


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

Open in new window


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) + @"""";
        callImgMagick(arg);
        displayImg(imgSrc, 5000);
    }

Open in new window


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'
0
Comment
Question by:Nate_LR
1 Comment
 

Accepted Solution

by:
Nate_LR earned 0 total points
ID: 40253650
I figured out that I needed to do this...
<asp:Image ID="Image1" runat="server" Width="1000px" ImageUrl='<%# Bind("relPath", "FieldPics/{0}") %>' />

Open in new window


instead of this...
<asp:Image ID="Image1" runat="server" Width="1000px" ImageUrl='FieldPics/<%# Eval("relPath") %>' />

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question