【问题标题】:How can i find img src value from a Text with asp.net? [duplicate]如何使用 asp.net 从文本中找到 img src 值? [复制]
【发布时间】:2018-03-12 17:25:31
【问题描述】:
我有一个这样的 html 文本:
string htmltext="<p style="text-align: left;" align="center"><img src="../image/1.jpg" alt="" width="310" height="162" /></p>";
我只想从此字符串中找到 src 值 (../image/1.jpg)。
请帮帮我。
【问题讨论】:
标签:
c#
html
asp.net
string
substring
【解决方案1】:
ASPX:
<p style="text-align: left;" align="center">
<img src="../image/1.jpg" alt="1" id="myImage" width="310"
height="162" runat="server" />
</p>
代码隐藏:
string src = myImage.Src;
Making Sense of ASP.NET Paths