When studying for my certification exams, one thing I read about that seemed cool is SmartNavigaiton. I must confess that I had not used this feature at all in the past. For those who do not know about SmartNavigation, it is a page-level asp.net property you can set that is supposed to fix a number of web page post back woes. This easily set property is used to prevent the page flicker, and the loss of state related to where the user was on the form before the post back. This sounded like a great thing to try on a web form where there is a post back event linked to a text box TextChanged event. In my case, I am calculating a total cost based on the amounts entered in a few text boxes. Without SmartNavigation, when the page posted back, the focus was back to the top of the form. This is an annoying behavior to my users who had to enter a few different values that went into the total calculation. Each time they changed an amount field, they were popped back up to the top of the form.
SmartNavigation does take care of this issue, although if a user is in a text box that causes post back, and they tab off the field, the post back happens and SmartNavigation puts the focus back into the textbox they just left. This is better than moving them back to the top of the form. However, once I added a few more user controls and a style to my page, I ran into problems. I did not get a page error. Instead, IE reported a fatal error and my web browser closed. This happened to me repeatedly.
I followed my usual course of action when I run into crazy, unexpected behavior. I went to Google. I found a blog post by Karsten Samaschke dedicated to SmartNavigation, and why not to use it. In my situation, my style sheet may be the culprit. For now, I think I will turn SmartNavigation off.
And I was so excited about using something I learned while studying for the cert tests…
Friday, May 27, 2005
Subscribe to:
Post Comments (Atom)
4 comments:
While SmartNavigation is not necessarily the work of the devil, it is the work of the devil's henchmen. I refuse to use it because I've had so many problems with it as well.
I also ran into a lot of trouble with SmartNavigation, once my stylesheet disappeared every time a postback occurred :( (Some people posted solutions on my blog: http://dotnet.org.za/thea/archive/2004/04/02/949.aspx)
In my searches I found some alternative solutions to maintain your scroll position without using SmartNavigation:
http://aspalliance.com/356
http://blogs.prenia.com/cathi/PermaLink.aspx?guid=c634ab31-bab6-467e-a838-3790af0b1041
Thea :)
Thank you, Thea. I will try adding my own javascript to control scroll position, and it sounds like the consensus view is that if you use SmartNavigation, you aren't making a smart decision :)
AS far as Focus problem of SmartNavigation is concerned u can remove that functionality form "SmartNavigation.js". To maintain focus on pages yr self you can change following function of js.Code is as follows
window.__smartNav.restoreFocus = function()
{
return; // it will return and not set focus
if (window.__smartNav.inPost == true) return;
var curAe = document.activeElement;
var sAeId = window.__smartNav.ae;
if (sAeId==null || curAe!=null && (curAe.id==sAeId||curAe.name==sAeId))
return; var ae = document.all(sAeId);
if (ae == null) return;
try {
//ae.focus();
} catch(e){};
}
Post a Comment