Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
HI, i need to develop web based system that are web application for my project paper. for it i have to convert URL to image in website. That are, firstly i must insert URL in textbox then click browse button. Once click it have to show the images of the URL. Please i need code for this. i could not find any code to convert. Please help me. Im using asp.net c# in VS 2010 ultimate.
Posted
Updated 27-Feb-15 3:15am
v2
Comments
Sergey Alexandrovich Kryukov 27-Feb-15 9:15am    
Sorry, all your post does not seem to make sense, starting from its title. "Convert" is just the absurd, as many other things. It's possible that you want to do something reasonable, only your wording is wrong. Then you can edit it using "Improve question".
—SA
ZurdoDev 27-Feb-15 9:25am    
You want to get all images from a page? Search that way, don't search for convert.

You can use the WebClient class and possibly even the HTML Agility Pack to parse our the images. http://htmlagilitypack.codeplex.com/

A URL is an address to a file, whether it is local (your webserver) or remote (someone elses webserver). A URL "points" to an image, in the same way that a file path and file name points to a file on your hard drive. The URL allows your web application to display the image on a web page.

For example:
HTML
 Remote image:
 <div>
     <img src="http://someremotewebsite.com/images/remoteImage.jpg" alt="Alternate text in case your image does not display" />
 </div>

Local image (assumes using .NET Framework) :
 <div>
      <img src="~/images/localImage.jpg" alt="Alternate text in case your image does not display">
 </img></div>
 
Share this answer
 
you can create like this....


HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head  runat="server">
    <title></title>
</head>
<body>
    <form id="form1"  runat="server">
    <div>
        <asp:scriptmanager id="ScriptManager" runat="server">
        </asp:scriptmanager>
        <asp:updatepanel id="UpdatePanel" runat="server">
            <contenttemplate>
                <table>
                    <tr>
                        <td>
                            <asp:textbox id="txtImgUrl" runat="server"></asp:textbox>
                        </td>
                        <td>
                            <asp:button id="btnShow" runat="server" text="Show" onclick="btnShow_Click" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:label id="lblMessage" runat="server" visible="false"></asp:label>
                        </td>
                    </tr>
                </table>
                <br />
                <div>
                    <asp:image id="imgView" runat="server" alternatetext="Image Goes Here" visible="false" />
                </div>
            </contenttemplate>
        </asp:updatepanel>
    </div>
    </form>
</body>
</html>


and code behind like...

C#
protected void btnShow_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtImgUrl.Text))
            {
                imgView.ImageUrl = txtImgUrl.Text;
                imgView.Visible = true;
            }
            else
            {
                lblMessage.Visible = true;
                lblMessage.Text = "Please add Url to text box";
            }
        }


and use image url like this...

https://www.google.co.in/images/srpr/logo11w.png[^]
 
Share this answer
 
v3
Comments
Member 10744108 27-Feb-15 10:15am    
Tq. but it shows only one error on this

imgView.ImageUrl = txtImgUrl.Text;
imgView.Visible = true;

Why? do you have solution for tiz?
Tejas Vaishnav 2-Mar-15 1:20am    
what you have pasted in your text box? which type of url you are using?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900