Fixing the Jumping AJAX Rating Control
February 22nd, 2008If you are using the Rating Control for the ASP.NET AJAX Control Toolkit on a long page you will notice that after selecting your rating the page jumps to the top of the screen. On a short page you will not notice anything but the hash sign appearing at the end of the URL. On a long page the jump is a big problem. It is due to the href attribute on the anchor tags being set to a hash instead of something like javascript:void(0); which would prevent the jumping. I fixed this with one line of JavaScript using jQuery to set the link value to ensure clicking does not have the unwanted side-effect.
In the below sample I have the Rating Control wrapped in a div tag with Rating set as the CSS class. This way I can have many ratings on one page and having this one line fix all of them.
March 4th, 2008 at 7:58 am
Hello,
Nice topic.
Can you please tell me where to put the following line?
$('div.Rating a').attr('href', 'javascript:void(0);');
Take care.
Bye,
March 4th, 2008 at 1:02 pm
@Naveed,
You need to run this line after the page has loaded. In jQuery you could use the "ready" function and with ASP.NET AJAX you could use Sys.Application.add_load(fn).
March 4th, 2008 at 11:10 pm
Thanks for your reply. I am using ASP.Net 2.0. Can you please tell me where to put this "Sys.Application.add_load(fn)"?
Can you please tell me in which function should I place this? And In .aspx form or in .aspx.vb file?
Thanks.
Take care.
Bye,