Asp.net 替换c中的子节点#
我有一个字符串HTML代码,如Asp.net 替换c中的子节点#,asp.net,string,c#-4.0,Asp.net,String,C# 4.0,我有一个字符串HTML代码,如 <table id='topInfoBar' style=" width: 100%;" cellspacing='0' border='0'> <Tr> <td id='lockOrder' clientidmode='static' style="text-align:Right;color:black;font-weight:bold"> <img src='.../images/locked.gif'
<table id='topInfoBar' style=" width: 100%;" cellspacing='0' border='0'>
<Tr>
<td id='lockOrder' clientidmode='static' style="text-align:Right;color:black;font-weight:bold">
<img src='.../images/locked.gif' alt='This order is locked' title='This order is locked!' />
</td>
</Tr>
</table>
我想检查字符串中是否存在id'lockOrder',如果是,我想替换img节点,即
与
要在c#中执行此操作。使用属性
可见
并在
HTML
你试过什么吗?直接字符串操作是否有问题,例如
myHtmlString.Contains(“lockOrder”)
和myHtmlString.Replace(oneImgLine,anotherImgLine)
?这不是最有效的方法,但应该是有效的。您是在询问如何在ASP.NET页面中显示/隐藏元素,还是如何替换HTML字符串中的文本?您的问题不包含任何与ASP相关的内容。NET@PanagiotisKanavos这是一个包含HTML代码的字符串,希望从代码中进行操作。我不认为这是一个ASP.NET问题。此外,使用此代码只能在webforms中使用
<i class="fa fa-search fa-2x cursorpointer" title="This order is locked"></i>
<table id='topInfoBar' style="width: 100%;" cellspacing='0' border='0'>
<Tr>
<td id='lockOrder' clientidmode='static' style="text-align: Right; color: black; font-weight: bold">
<img src='.../images/locked.gif' alt='This order is locked' title='This order is locked!' runat="server" id="img"/>
<i class="fa fa-search fa-2x cursorpointer" title="This order is locked" runat="server" id="i" Visible="False"></i>
</td>
</Tr>
</table>
if (true)
{
img.Visible = false;
i.Visible = true;
}