gpt4 book ai didi

c# - 编辑 ASP.NET 控件的内容

转载 作者:太空宇宙 更新时间:2023-11-03 20:27:46 25 4
gpt4 key购买 nike

下面是我的Default.aspx的内容

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
WELCOME
</h2>
<p id="exampleId">
I want to edit here
</p>

</asp:Content>

我希望能够找到 ID 为“exampleID”的控件,并使用 C# 向其中写入一些内容。

最佳答案

runat = "server" was missing in the tag to access it from code behind.

HTML

<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<h2>
WELCOME
</h2>
<p id="exampleId" runat = "server">
I want to edit here
</p>

</asp:Content>

C#代码

exampleId.InnerText = "Your text";

关于c# - 编辑 ASP.NET 控件的内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9465731/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com