views:

1341

answers:

2

Hi I have a tabpanel with a calendar control on the 4th tab but when I select a date, the postback causes the tabpanel to return to the first tab instead of the 4th that it came from. Is there a way to get it to return to the tab that the calendar control is on and not revert back to the first tab ?

I know setting autoPostback to true on the TabContainer will do this but that means it reloads on every tab change not just the one I want.

Any ideas ?

A: 

Wrapping the contents of the fourth tab in an UpdatePanel control should do the trick.

<ajaxToolkit:TabPanel runat="server" ID="tabCS" HeaderText="Country Settings">
  <ContentTemplate>
    <asp:UpdatePanel runat="server" ID="upCountry" UpdateMode="Conditional">
      <ContentTemplate>

          ... content and calendar

       </ContentTemplate>
    </asp:UpdatePanel>
  </ContentTemplate>
</ajaxToolkit:TabPanel>
Hmobius
A: 

Here is a best practice that I've found.

Unless other tabs in the tab panel need to be updated only put the contents of each panel in an update panel. If you need to update other panels you can call the method programmatically to update them.

There are two good reasons for this: 1.) By putting update panels in the tabs you will have fewer bits to get back from the server. 2.) Calling the update methods programmatically makes you more aware of what it is you are providing the end user and you won't forget to update the data.

Remember that if you use multiple panels to change the update mode from always to conditional so that only the relevant information is updated on the client.

Also if you want to put the entire tab panel control into the update panel you may need to add any formatting that is done to a CSS file since my experience is that it fails to retain the default formatting with it updates.

If you need more info or a code sample just message me.

Andrew

Middletone