Aspx.vb – HTML ?

[sub]grrrrrr.[/sub]

I have an application that calls an aspx.vb page. That page is going to do some database work and then dynamically build the HTML for display to the user.

For instance –

    Dim table1 As New System.Web.UI.WebControls.Table
    Dim row As New System.Web.UI.WebControls.TableRow
    Dim cel As New System.Web.UI.WebControls.TableCell
    
    row.Cells.Add(cel)
    table1.Rows.Add(row)

    Me.Controls.Add(table1)

All I want to do is add a <Center> tag to the page in the body. But I’m can’t seem to find out how to do it.

Thanks

If you’re just trying to center your table, you can probably do that more easily without a <CENTER> tag… just say

table1.attributes.add “align”, “center”

…which has the effect of adding an ‘align=“center”’ attribute to your table tag.

For actually adding a <CENTER> tag to the page consistently with that sort of notion, I think you could add a System.Web.UI.WebControls.Literal object to Me, and then set the literal’s text to be “<CENTER>” (You’d probably want to use another Literal for the </CENTER>)

I’m not very familiar with this style of doing everything in the .aspx.vb file - what’s in the .aspx file itself? Just a reference to the .aspx.vb??

With the development style I’m used to, you’d put the asp:table in your aspx file, and static formatting like the <CENTER> tags. If you put the table in .aspx as

<asp:table id=‘table1’ runat=‘server’/>

And declare it in the .aspx.vb file as:

protected table1 as System.Web.UI.WebControls.Table

Then you don’t need to bother with a me.controls.add statement - the table is already part of the controls collection of your page object. This, to me, is much easier to deal with.

Hope my answer was helpful - if you have any followup questions, please ask.

:smack:

This is my first shot at ASP.NET

I added the <center> tag to the .aspx. I certainly could also add the table there too. Then in the .vb dynamically build it. It’s going to have different rows, row spans, colspans and the like depending on the query.

Thanks