Got more questions? Find advice on: SQL | XML | Regular Expressions | Windows
in Search
Welcome to AspAdvice Sign in | Join | Help

C# Nuggets

More Gripes

Following on from my last post on ASP.Net, here are some more:

  • When you define a FormView control without a header or footer template, you still incur the cost of the header and footer in ViewState. Yes - the FormView dev created table rows for the header and footer, added them to the Controls collection and set them to invisible prior to the SaveViewState phase - meaning you get an extra 48 bytes (according to trace.axd) of overhead for no reason.
  • Page_Load, Page_Unload etc ignore ConditionalAttribute applied to them. (Or rather the ASP.Net event hookup framework ignores ConditionalAttribute)
  • Why doesn't the GridView have a TotalRowCount property? By default GridView uses a dataset and knows how to page. Indeed, a FormView has something similar to enable  you to get the Total row count. But a GridView doesn't.
  • Using the rowstyle wrap attribute like <asp:gridview><rowstyle wrap="false"/></asp:gridview> does not work in IE. You have to set every column individually.
  • The onClientClick event is broken - the databinding expression has to be at the start of the string. eg: have a look at what gets rendered for the following: <asp:button runat="server" Text=" <%#Container.DataItem %>" onclientclick='    <%#Container.DataItem %>)'/>. Notice how the text/value is fine, but the onclientclick/onclick is a mess. Then when you try to put quotes inside of the event (for example a Javascript Confirm() ), ASP.Net just doesn't allow this scenario. eg onclientclick='<%# "confirm('" + Container.DataItem + "')" %>'. The only workaround I could think of was to set an expando attribute to the databound expression, then refer to that attribute from Javascript on the client side...
I'd like to re-iterate that I really like ASP.Net, especially v2. I just can't wait for that Q3 2006 service pack.
Published Thursday, January 26, 2006 10:50 AM by rbirkby

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

C# Nuggets said:

The gripes series continues. This is an occaisional series on the problems I've found with ASP.Net v2....
May 11, 2006 5:38 AM
 

thorn said:

> eg onclientclick='<%# "confirm('" + Container.DataItem + "')" %>'. The

> only workaround I could think of was to set an expando attribute to the

> databound expression, then refer to that attribute from Javascript on

> the client side...

Try this:

onclientclick='<%# "confirm(\"" + Container.DataItem + "\")" %>'

April 2, 2008 6:25 AM
 

MDH said:

Thanks for the solution! I've been trying to figure that out.
July 8, 2008 8:25 AM

Leave a Comment

(required) 
(optional)
(required) 
Enter the code you see below

Submit