Re: aspx variable replacement - runat=server

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Karl Seguin (_at_)
Date: 01/28/05


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
>


Relevant Pages

  • Re: ASP.NET
    ... ASP net must be registered with IIS by running: ... The results of your asp page should be the same as your aspx. ... I downloaded and installed the Microsoft.NET Framework. ... Using the code in a kind of Scripting way inside the HTML code not ...
    (microsoft.public.dotnet.general)
  • Re: date format.
    ... a dd/mm/yy format. ... yyyy/mm/dd for the stored procedure to run. ... > The html code for my form is as follows ... > Not even sure if asp is needed to do this. ...
    (microsoft.public.inetserver.asp.db)
  • Re: how to make FP 2002 form with FP extensions on server??
    ... For sending mail using CDONTS and ASP see ... > My web hosting company doesn't support FP extensions at this time. ... > the html code for making a simple submit type form in FP2002? ...
    (microsoft.public.frontpage.extensions.windowsnt)
  • ASP or HTML in asp file
    ... I am just curious as to when it is better to use straight HTML or ASP ... to put out HTML code on an ASP page. ... Thank-you for visiting The Ultimate Parenting Resource. ...
    (microsoft.public.inetserver.asp.general)