Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

HTML Server Controls Seem to Make Pages very long

I want to create what would look like this in ASP 3:
...
dim s
s = "A whole lot of html"
%>
<table><tr><td><%=s%></td></tr></table>
...

in ASP.NET I do the following:
...
<table><tr><td id="cellName" runat="server"/>
...
then in the C# codebehind I have:
...
protected HtmlTableCell cellName;
s = "A whole lot of html";
cellName.InnerHtml = s;
...

This works fine, except that my string "s" is very long, and the resulting blob of text that ASP.NET generates to remember the "state" of the page gets very long as well.

Any thoughts on how to manage the length of that automatically generated string?

Charles Reich
Friday, January 17, 2003

...<td id="cellName" runat="server" ENABLEVIEWSTATE='FALSE' />...

or

<% Page .... EnableViewState='false' ...%>

or in web.config:

<page enableViewState='false' ... />

or don't bother with making the tag "runat=server" and just do as you did before:

<table><tr><td><%=s%></td></tr></table>

alternatively if you want to control when "s" gets evaluated then use DataBinding:

<table><tr><td><%# s %></td></tr></table>

... call Page.DataBind() when you want the "<%#%>" tage evaluated.

HTH

Duncan Smart
Friday, January 17, 2003

... "s" being a field or property in your code-behind page marked as "protected" or "public"

Duncan Smart
Friday, January 17, 2003

Thanks Duncan. EnableViewState="false" worked like a charm.

Charles Reich
Friday, January 17, 2003

*  Recent Topics

*  Fog Creek Home