C# 编辑ASP.NET控件的内容

C# 编辑ASP.NET控件的内容,c#,asp.net,.net,C#,Asp.net,.net,下面是my Default.aspx的内容 <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <h2> WELCOME </h2> <p id="exampleId"> I want to edit here </p> </asp:Content

下面是my 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”,无法从代码隐藏中访问它

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>
标记中缺少runat=“server”,无法从代码隐藏中访问它

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>

您在这里几乎没有选择:

  • 添加runat=“服务器”
  • 在p中添加asp.net服务器端控件“文本”

    
    

    不要为此使用标签,因为这将使用额外的跨度进行渲染,这是您不希望的


  • 希望有帮助。

    您在这里几乎没有选择:

  • 添加runat=“服务器”
  • 在p中添加asp.net服务器端控件“文本”

    
    

    不要为此使用标签,因为这将使用额外的跨度进行渲染,这是您不希望的


  • 希望有帮助。

    将其制作成一个
    runat=“server”
    控件。使用asp.net提供的一个控件怎么样?类似于
    ,可以通过
    exampleId.Text=“你好,世界!”)访问它请不要在标题中包含C,只需将其标记为C,谢谢!将其设置为
    runat=“server”
    控件。使用asp.net提供的一个控件怎么样?类似于
    ,可以通过
    exampleId.Text=“你好,世界!”)访问它请不要在标题中包含C,只需将其标记为C,谢谢!
    
    <p>
        <asp:Literal ID="exampleId" runat="server" />
    </p>