I have a simple web page with 5 tabs. Each tab is a LinkButton. The main body is a <div> and I place a PlaceHolder inside it. Now, I want to make a click event on the tabs, so whenever I click on one of the tabs, the PlaceHolder will be changed accordingly. So, I have two question here:
-
How can I disable the
PostBackand make theLinkButtononly updates thePlaceHolder(using C#)? -
Can I load/reload the
PlaceHolderwith a HTML Page?
Thanks.
If you want all of this to happen without postbacks then I recommend moving away from server-side controls like
LinkButtonandPlaceHolder. What you’re trying to achieve is much more easily done as a client-side concern.Take a look at the jQuery UI tabs. Looking through the code in various demos (click on “view source” on that page to see how simple the HTML is), you can see that it’s just attached to regular HTML. Nothing server-side. By making your tab headers plain HTML elements (
li/aelements in the demos) you get around the whole “postback” thing, which you don’t want anyway.There’s nothing really special happening on these tabs. Clicking each one just updates the CSS for the tab elements (
divs in this case) to change theirdisplayproperty, hiding and un-hiding accordingly.One thing to note is how the code treats this separation of server-side and client-side functionality. From the perspective of the server-side code (the ASP.NET stuff), it’s all one page. There’s nothing dynamic or special happening. It renders the whole page like any other. The client-side code (the JavaScript/CSS/HTML stuff) is providing the user experience entirely unknown to the server-side code. As far as ASP.NET is concerned, it’s delivering a page to the browser. Nothing more.