如何使用href元素获取存储在服务器上的图像并显示为链接。 [英] How to get an image stored on a server and display as a link using an href element.

查看:59
本文介绍了如何使用href元素获取存储在服务器上的图像并显示为链接。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我使用c#进行编码。我有一个我正在使用的gridview。我正在创建一个新行,如下所示。



transDescription
href
正在打开URL的点击元素是一个新窗口。


此网址由网络服务返回,此内容的值包含在transImageURL字段中


我已经给出了完整的代码供您参考。


 public DataTable getTable(){//获取事务的记录并将其存储在listm_HistoryList = (//调用webservice以获取transDescription,transDate,transImageURL等详细信息)m_dtHistory = new DataTable(); m_dtHistory.Columns.Add(new DataColumn(" transDescription",typeof(string))); m_dtHistory.Columns.Add (new DataColumn(" transDate",typeof(string))); foreach(m_HistoryList中的BusinessObject.History元素){DataRow drHistory = m_dtHistory.NewRow(); if(!str ing.IsNullOrEmpty(element.transImageURL)){drHistory [" transDescription"] ="< a style ='color:#003399;'href ='" + element.transImageURL +"'target ='_ blank'>" + element.transDescription +"< / a>" ;; } else {drHistory [" transDescription"] = element.transDescription; } drHistory [" transDate"] = element.transDate; } return m_dtHistory; } 

现在需求已经改变。 Web服务现在将图像复制到服务器上的某个位置,例如10.10.10.10 \ C:\ Image.DisplayImage.jpg


此服务器已公开到互联网,所以我可以从我的应用程序访问图像,这也是在互联网上。
现在,transImageURL将包含此文件的路径而不是URL。


我需要从此路径获取图像并将其分配给 href
元素,以便点击
transDescription 字段,现在通过引用此路径而不是使用URL来打开图像。


请告诉我如何实现这一目标?


问候,


Raj

解决方案

你好,


 


您的项目是否基于Windows Phone 7?如果是这样,我建议您在
中打开一个新主题 Windows Phone 7论坛。
  我将把这一个移到偏离主题。


 


最好的问候,


杰西


Hi,

I am using c# to do my coding. I have a gridview which I am using. I am creating a new row as shown below.

The transDescription is a href element on click of which a URL is being opened is a new window.

This URL is being returned by a webservice and the value for this is contained in transImageURL field

I have given the complete code below for your reference.

public DataTable getTable(){            //Get the records for the Transactions and store it in a listm_HistoryList = (//Call the webservice to get the details like transDescription, transDate, transImageURL)m_dtHistory = new DataTable();m_dtHistory.Columns.Add(new DataColumn("transDescription", typeof(string)));m_dtHistory.Columns.Add(new DataColumn("transDate", typeof(string)));foreach(BusinessObject.History element in m_HistoryList){DataRow drHistory = m_dtHistory.NewRow();if(!string.IsNullOrEmpty(element.transImageURL)){  drHistory["transDescription"] = "<a style='color:#003399;' href='" + element.transImageURL + "'target='_blank'>" + element.transDescription + "</a>"; } else {   drHistory["transDescription"] = element.transDescription; } drHistory["transDate"] = element.transDate; }  return m_dtHistory; }

The requirement has now been changed. The web service will now copy the image in a location on the server for eg 10.10.10.10\C:\Image\DisplayImage.jpg

This server is exposed to the internet so I can acces the image from my application which is also on the internet. So now the transImageURL will contain the path to this file instead of the URL.

I will need to get the image from this path and assign it to the href element in my code above so that on click of the transDescription field, the image is now opened by referring to this path instead of using the URL.

Could you please let me know how I can achieve this?

Regards,

Raj

解决方案

Hello,

 

Is your project based on Windows Phone 7? If so, I would suggest you to open a new thread in Windows Phone 7 Forum.  I will move this one to off-topic.

 

Best regards,

Jesse


这篇关于如何使用href元素获取存储在服务器上的图像并显示为链接。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆