在服务器端更改html标记文本(C#,ASP.NET) [英] change html tags text , on server side (C#, ASP.NET)

查看:91
本文介绍了在服务器端更改html标记文本(C#,ASP.NET)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以在服务器端更改html客户端标签文本吗?



例如,在服务器端更改h2或p标签文本?

$例如:b
$ b

< asp:Content ID =BodyContentrunat =服务器ContentPlaceHolderID =MainContent> 
< h2>
欢迎来到ASP.NET!
< / h2>
< p>
要了解有关ASP.NET的更多信息,请访问< a href =http://www.asp.nettitle =ASP.NET网站> www.asp.net< / a> ;.
< / p>
< p>
您还可以找到< a href =http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409
title =MSDN ASP.NET Docs >有关ASP.NET在MSDN上的文档< / a> ;.
< / p>





将h2文字从欢迎来到ASP.NET!到Hello。 首先添加一个ID和 runat =server元素:

 < h2 id =myHeaderrunat =server> 

然后在 Page_Load 方法中: p>

  myHeader.InnerHtml =Hello; 


can i change html client tags text , on the server side?

like for example, change h2 or p tags text on server side?

for example:

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
    Welcome to ASP.NET!
</h2>
<p>
    To learn more about ASP.NET visit <a href="http://www.asp.net" title="ASP.NET Website">www.asp.net</a>.
</p>
<p>
    You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&amp;clcid=0x409"
        title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
</p>

change the h2 text from "Welcome to ASP.NET!" to "Hello".

解决方案

First add an ID and runat="server" to the element:

<h2 id="myHeader" runat="server">

Then in the Page_Load method:

myHeader.InnerHtml = "Hello";

这篇关于在服务器端更改html标记文本(C#,ASP.NET)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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