Create custom tags? RRS feed

  • Question

  • User-188219181 posted


      I am very new to ASP.NET and C#, coming from a world of PHP.  I have a (hopefully) simple question.

      I would like to create a sort of customer tag, for example: I want to be able to define an area, like such:


      And be able to put that in an html layout like such:

      <asp:whatever>this is a test</asp:whatever> (?)

      The ideal result would be:

      <table>........<td>this is a test</td>........</table>

      There would be no actual C# in the code, just a basic table layout.

      Any help would be greatly appreciated =]


    Tuesday, October 20, 2009 8:10 PM


  • User2077888689 posted


    You can directly use HTML tags in ASP.NET markup just like you do in a HTML file. So you want to build table you write,



     <td> Some Data </td>



    However note that if you manipulate this table in the server side you need to add the following attributes,

    1. runat="server"

    2. id="myTable" - This isn't mandatory since asp.net will generate an Id by itself, however for refering the control in the server side you need this.

    so the above declaration would some thing like this,

    <table runat="server" ID="myTable">



    Asp.Net also comes with <asp:Table> class which will also render the <table> tags. You can use this as well,

    <asp:Table id="myTable" runat="server">
    Row 0, Col 0
    Row 0, Col 1
    Row 1, Col 0
    Row 1, Col 1

    Hope this helps!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 21, 2009 3:38 AM