Re: aspx variable replacement - runat=server
From: Karl Seguin (_at_)
Date: 01/28/05
- Next message: Ken Cox [Microsoft MVP]: "Re: Web Parts"
- Previous message: Ken Cox [Microsoft MVP]: "Re: Urgent: Need some advice on Connection"
- In reply to: testemail_at_skunkbox.com: "aspx variable replacement - runat=server"
- Next in thread: testemail_at_skunkbox.com: "Re: aspx variable replacement - runat=server"
- Reply: testemail_at_skunkbox.com: "Re: aspx variable replacement - runat=server"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 28 Jan 2005 09:11:25 -0500
Phil:
In ASP.Net it's just as simple but far more flexible. The entire point of
having a runat="server" is that it creates a rich and capable server-side
object, in this case an HtmlTableCell. Instead of messing up your html code
with <%= %> you can program against your objects to set their variables.
In other words:
<asp:TableCell id="cellContent" runat=server>...</asp:TableCell>
and then you can do, in the Page_Load event:
cellContent.ColumnSpan = NumberOfCols
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/ <testemail@skunkbox.com> wrote in message news:1106879091.075883.160280@f14g2000cwb.googlegroups.com... > Hello > > How do I perform a variable replacement in ASP.NET when I am using the > runat=server clause to generate a table - it was simple in ASP > > With ASP : > ---------- > <HTML> > ... > <BODY> > ... > <TABLE...> > <TR> > <TD colspan="<%=NumberOfCols%>">...<TD> > ... > <TR> > ... > <TABLE> > ... > </BODY> > </HTML> > > With ASP.NET : > -------------- > <HTML> > ... > <BODY> > ... > <asp:Table... runat=server> > <asp:TableRow runat=server> > <asp:TableCell ColumnSpan="<%=NumberOfCols%>" > runat=server>...</asp:TableCell> > ... > </asp:TableRow> > ... > </asp:Table> > ... > </BODY> > </HTML> > > Then the Code Behind contains > ... > Protected NumberOfCols As Integer = 6 > ... > > > But executing the above <%=NumberOfCols%> is not a valid value for > Int32. > > However if I print the variable by placing <%=NumberOfCols%> somewhere > within the body of the html it prints the value of it ("6") correctly. > Can anyone help ? > > Cheers > Phil >
- Next message: Ken Cox [Microsoft MVP]: "Re: Web Parts"
- Previous message: Ken Cox [Microsoft MVP]: "Re: Urgent: Need some advice on Connection"
- In reply to: testemail_at_skunkbox.com: "aspx variable replacement - runat=server"
- Next in thread: testemail_at_skunkbox.com: "Re: aspx variable replacement - runat=server"
- Reply: testemail_at_skunkbox.com: "Re: aspx variable replacement - runat=server"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|