开发者

How to replace a td with elements with empty td

Hi i have a structure like

<td valign="top" style="width:150px;" > 
     <img alt="<recipetitle/>" src="http://<rootweburl/>/photos/recipes/Large/<recipephotoname/开发者_运维百科>" alt="logo" style="float:left;"/> 
</td>

Where <recipetitle/> and <recipephotoname/> are parameters and can change .I want to replace this td with a empty td .How will i do that in C#


You need to make your table cell a server side control so you can access it from code behind.

<table>
    <tr>
        <td valign="top" style="width:150px;" runat="server" id="tdToBeCleared">
            <img alt="<recipetitle/>" src="http://<rootweburl/>/photos/recipes/Large/<recipephotoname/>" alt="logo" style="float:left;"/>  
        </td>         
    </tr>
</table>

In codebehind, you can change the innerhtml of your control. If you want to clear the content, simply use the following line:

tdToBeCleared.InnerHtml = string.Empty;

Edit: Just changed the td to match with your example, you can simply copy and paste.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜