将图像上载到imgur,并使用C#应用程序内HTML代码中的链接 [英] Uplad an image to imgur and use the link in HTML code inside C# application
问题描述
我想将图像上传到imgur并在我的应用中使用它.我知道要上传并获得指向该图像的链接的代码,我的问题是,
1.我想永久地在应用程序内的html代码中设置该链接(见下文),直到我上传新图像为止.我正在使用链接,
I want to upload an image to imgur and use it in my app. I know the code to upload and get the link to that image, my questions are,
1. I want to set that link in a html code inside the app(see below) permanantly until i upload a new image. I''m using the link in,
<img src = ''http://i.imgur.com/Mix.png''>
2.如您所见,它是串联的.如何在img标签内动态设置URL?
2. as you can see it''s concatenated. How can i set the URL dynamically inside the img tag?
推荐答案
应为:
<img src = 'http://i.imgur.com/Mix.png' alt="My picture" />
如果这是ASP.NET或任何其他服务器端技术,并且在回发后替换了映像,则只需为src
生成一个新值.
您还可以随时通过JavaScript修改src
属性的值.最方便的方法是使用jQuery:
HTML:
If this is ASP.NET or any other server-side technology, and the image is replaced after a postback, you should simply generate a new value for the src
.
You can also modify the value of the src
attribute via JavaScript at any time. The most convenient way is using jQuery:
HTML:
<img id="myPicture" src = 'http://i.imgur.com/Mix.png' alt="My picture" />
JavaScript:
JavaScript:
img =
(" ); img.attr(" ," someOtherUrl.png");
("#myPicture"); img.attr("src", "someOtherUrl.png");
请参阅:
http://api.jquery.com/attr/ [ http://api.jquery.com/category/attributes/ [ http://en.wikipedia.org/wiki/JQuery [ http://api.jquery.com [ ^ ],
http://docs.jquery.com/Tutorials:How_jQuery_Works [ http://docs.jquery.com/Tutorials [
Please see:
http://api.jquery.com/attr/[^],
http://api.jquery.com/category/attributes/[^].
If you need to learn jQuery (highly recommended), please see:
http://en.wikipedia.org/wiki/JQuery[^],
http://api.jquery.com[^],
http://docs.jquery.com/Tutorials:How_jQuery_Works[^] (best place to start),
http://docs.jquery.com/Tutorials[^].
这篇关于将图像上载到imgur,并使用C#应用程序内HTML代码中的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!