ASP.NET - How to write some html in the page? With Response.Write?

前端 未结 8 1442
星月不相逢
星月不相逢 2020-12-31 00:52

I need that some html in the area in the asp.net page that i am coding, is changed according to a string variable. I was thinking about creating a label, and then change the

相关标签:
8条回答
  • 2020-12-31 01:29

    If you want something lighter than a Label or other ASP.NET-specific server control you can just use a standard HTML DIV or SPAN and with runat="server", e.g.:

    Markup:

    <span runat="server" id="FooSpan"></span>

    Code:

    FooSpan.Text = "Foo";

    0 讨论(0)
  • 2020-12-31 01:32

    If you really don't want to use any server controls, you should put the Response.Write in the place you want the string to be written:

    <body>
    <% Response.Write(stringVariable); %>
    </body>
    

    A shorthand for this syntax is:

    <body>
    <%= stringVariable %>
    </body>
    
    0 讨论(0)
提交回复
热议问题