I am developing an ASP.NET based website.
In a Master Page, I have a UL list, which is used to display links (akin to left nav). As of now, upon click of each li, the user is taken to respective page.
The problem is, when user is redirected to another page, the master page is also getting reloaded, as a result of which, the clicked-link is not highlighted. (All the UL is in a query accordion control).
Hence, I plan to use AJAX - i.e. whenever a user clicks a link in an accordion control, the corresponding page contents should be loaded and displayed in a place holder, so that the link is highlighted and user is aware of the current page info.
Please advise me as to how to achieve this (either thru' ASP.NET AJAX or Javascript AJAX)
The code in master page is as below:
script type="text/javascript">
// well all the DOM is written in the page and all elements are available do:
$(document).ready(function() {
// for each <a> tag bind the event click and now do:
$("a").click(function() {
// 1st. remove all selected
$("a.selected").removeClass("selected");
// 2nd. assign selected to this clicked element only
$(this).addClass("selected");
// 3rd. let's return true so the <a> tag can jump to the href
return true;
});
});
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
Haemostasis Kits
Test 1
Chromogenic SubstratesTest 3
Bio ReagentsTest 4
To have a feel of page, please visit: http://www.murandmur.in/test2/Products/products-exclusive.aspx
Thanks for help in advance!
The way I went about doing more-or-less the same thing is to build a web service (or page method), which gets the body HTML from the DB and returns it (as a simple text string). This takes care of the server-side. On the client side, use jQuery (which you use anyway) to make ajax calls to the web service. I used these two links as reference when I was starting out:
http://encosia.com/using-jquery-to-consume-aspnet-json-web-services/
http://dotnetslackers.com/articles/ajax/Using-jQuery-with-ASP-NET.aspx
Hope this points you in the right direction.