The Antidote to ASP.NET Smart Navigation

One of the issues I have with ASP.NET is that it is postback crazy. Virtually nothing of significance can be done in pure browser client code with ASP.NET out of the box.* You have to Submit() the specially formed ASP.NET HTML form to the server, and all the event magic happens server side.

While this is nice from an abstraction standpoint, it’s kind of a pain for the client. Having tons of postbacks in the middle of the form causes “flicker” and loss of page scroll position. It can also be a serious performance issue if you have tons of viewstate that gets submitted to the server over and over. I am definitely not a fan of doing a lot of stuff in JavaScript and DOM on the browser – been there, done that – but we almost have the opposite extreme in ASP.NET.

One of the tricks MS introduced to combat the loss of page scroll position on postback is something called SmartNavigation. Unfortunately, it’s horribly broken. A friend recently referred me to an article by Brad McCabe which outlines the most elegant workaround I’ve seen so far – it lets you retain page position between postbacks in a very generic way. And not a single named anchor in sight!

Better workarounds are on the horizon with ASP.NET 2.0. I hear we’ll be able to use XMLHTTP requests to do “background” postbacks in some scenarios. We’ve gone this route before, too. It works, but it’s still painful, mostly because the browser is a hideous development platform. If ASP.NET 2.0 can abstract away the pain, and retain browser compatibility, then I’m for it.

*Now, there are some third party ASP.NET server controls which expose a lot of exotic client side behaviors. But none of the default controls do.

Related posts

My Scaling Hero

Inspiration for Stack Overflow occasionally comes from the unlikeliest places. Have you ever heard of the dating website, Plenty of Fish? Markus Frind built the Plenty of Fish Web site in 2003 as nothing more than an exercise to help teach himself a new programming language, ASP.NET. The site

By Jeff Atwood ·
Comments

Wrangling ASP.NET Viewstate

Inspired by Scott Hanselman's recent post on ASP.NET viewstate wrangling [http://www.hanselman.com/blog/MovingViewStateToTheBottomOfThePage.aspx], here's a roundup of tips for dealing with that ornery viewstate stuff. The first rule of thumb, of course, is to turn it off whenever you can. But

By Jeff Atwood ·
Comments

Recursive Page.FindControl

I’m currently writing my first ASP.NET 2.0 website. VS.NET 2005 is worlds better than VS.NET 2003, but I was mildly surprised to find that Microsoft still hasn’t added a recursive overload for Page.FindControl. So, courtesy of Oddur Magnusson, here it is: private Control

By Jeff Atwood ·
Comments

ASP.NET NTLM Authentication - is it worth it?

At work, we have the luxury of assuming that everyone’s on an intranet. So when it comes to identity management on our ASP.NET websites, NTLM authentication is the go-to solution. Why trouble the user with Yet Another Login Dialog when you can leverage the built in NTLM functionality

By Jeff Atwood ·
Comments

Recent Posts

Stay Gold, America

Stay Gold, America

We are at an unprecedented point in American history, and I'm concerned we may lose sight of the American Dream.

By Jeff Atwood ·
Comments
The Great Filter Comes For Us All

The Great Filter Comes For Us All

With a 13 billion year head start on evolution, why haven’t any other forms of life in the universe contacted us by now? (Arrival is a fantastic movie. Watch it, but don’t stop there – read the Story of Your Life novella it was based on for so much

By Jeff Atwood ·
Comments
I Fight For The Users

I Fight For The Users

If you haven’t been able to keep up with my blistering pace of one blog post per year, I don’t blame you. There’s a lot going on right now. It’s a busy time. But let’s pause and take a moment to celebrate that Elon Musk

By Jeff Atwood ·
Comments
The 2030 Self-Driving Car Bet

The 2030 Self-Driving Car Bet

It’s my honor to announce that John Carmack and I have initiated a friendly bet of $10,000* to the 501(c)(3) charity of the winner’s choice: By January 1st, 2030, completely autonomous self-driving cars meeting SAE J3016 level 5 will be commercially available for passenger use

By Jeff Atwood ·
Comments