How do you create a dynamic tab control in ASP.net that doesn't trigger a postback?
I want to create a dynamic, role-based tab control that doesn't trigger a postback when the user switches between tabs. Does开发者_如何学运维 anyone have any suggestions on approaches to accomplish this?
You can use the ASP.NET AJAX Control Toolkit It has a tab control that is fully configurable and will not postback.
Sure, this is possible. But the key thing to remember here is that the content for the tabs has to come from somewhere. If you don't send a postback when changing tabs you'll have to do one of two things:
- Send the content for all the tabs with each request. This can be expensive — literally. It can mean a lot of money in bandwidth costs sending data down the wire that most users might never see. On the other hand, if ever user visits most of the tabs on each visit, this would be the way to go. You know your app and your users, we don't, so that's a decision you'll have to make.
- Use ajax requests to retrieve data for each tab. This uses less bandwidth, but gets messy if you're thinking about it in terms of webforms. It pushes you into the realm of dynamic controls, and there be dragons. Again, if your comfortable with all the ajax requests and dynamic controls, this might be a perfectly fine solution for you, but that's something only you can know.
What I would do is give each tab it's own aspx page, so that switching between tabs actually loads a new page. I might also use a master page to keep the look and feel consistent. That means still doing what amounts to a postback for each tab, but it does it in a much cleaner way.
精彩评论