How to refresh on tab change?

Last post 11-13-2009 10:29 AM by mychucky. 16 replies.

Sort Posts:

  • How to refresh on tab change?

    10-23-2009, 3:56 PM
    • Contributor
      3,377 point Contributor
    • mychucky
    • Member since 03-20-2006, 5:01 PM
    • Posts 2,530

    I'm using a TabContainer. Is there a way to refresh/rebind everything once a tab is selected? Currently, it does not matter if the tab as changed or not, nothing in the selected tab is updated.

  • Re: How to refresh on tab change?

    10-24-2009, 1:13 AM
    • Member
      5 point Member
    • suyash123
    • Member since 04-16-2009, 7:37 AM
    • India
    • Posts 39

    First of all tell me are u using Ajax toolkit controls?


    If you are using a Ajax toolkit's tabcontainer there is property of tabpanel as onclick and onclientclick events

    onclick  makes a post back . and where as onclientclick is to call a javascript function on client side...


    You should go in source code of aspx file and check the propertieds if it!

  • Re: How to refresh on tab change?

    10-26-2009, 9:06 AM
    • Contributor
      3,377 point Contributor
    • mychucky
    • Member since 03-20-2006, 5:01 PM
    • Posts 2,530

    I see. Yes, I'm using Ajax Control Toolkit tabcontainer control.


  • Re: How to refresh on tab change?

    10-26-2009, 9:10 AM
    • Participant
      878 point Participant
    • dangerouschotu
    • Member since 10-11-2008, 12:10 PM
    • Jaipur
    • Posts 318

    use asp.net menus control if you want to postback the tabs instead of ajax tabs.

    Thanks & Regards,
    Please 'mark as answer' my post if they are helpful.
  • Re: How to refresh on tab change?

    10-27-2009, 2:06 AM

     If you want to rebind the data control inside tabpanel, you can define OnActiveTabChanged event to rebind the datasource of the corresponding control.


    Vince Xu
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: How to refresh on tab change?

    10-27-2009, 8:41 AM
    • Contributor
      3,377 point Contributor
    • mychucky
    • Member since 03-20-2006, 5:01 PM
    • Posts 2,530

    Vince Xu - MSFT:

     If you want to rebind the data control inside tabpanel, you can define OnActiveTabChanged event to rebind the datasource of the corresponding control.

    Thanks! I'll give that a try.

  • Re: How to refresh on tab change?

    10-27-2009, 9:13 AM
    • Member
      402 point Member
    • Rakeshkr
    • Member since 10-09-2009, 10:55 AM
    • Bangalore
    • Posts 82

    make autopostback properties of tab container is true and 

    write code in the event ActiveTabChanged

    sample code:------

    //protected void ajaxtabDRCamp_ActiveTabChanged(object sender, EventArgs e)
        //{
        //    string projectId = Convert.ToString(Session["ProjectId"]);
        //    if (object.Equals(projectController, null))
        //        projectController = new ProjectController();
        //    if (projectController.IsProjectAssignToProgramOfficer(loginSession.UserName, projectId))
        //    {
        //        switch (ajaxtabDRCamp.ActiveTabIndex)
        //        {
        //            case 0:
        //                if (ViewState["BaseHosCount"] == null)
        //                {
        //                    BaseHospotalEdit();
        //                    ViewState["BaseHosCount"] = "1";
        //                }
        //                break;
        //            case 1:
        //                if (ViewState["ScreenCount"] == null)
        //                {
        //                    DRScreenCampEdit();
        //                    ViewState["ScreenCount"] = "1";
        //                }            
        //                break;
        //            case 2:
        //                if (ViewState["AwareCount"] == null)
        //                {
        //                    DRAwarenessEdit();
        //                    ViewState["AwareCount"] = "1";
        //                }      
                        
        //                break;
        //        }                      
              
        //    }
        //    else
        //    {
        //        switch (ajaxtabDRCamp.ActiveTabIndex)
        //        {
        //            case 0:
        //                if (ViewState["BaseHosCount"] == null)
        //                {
        //                    BaseHospotalView();
        //                    ViewState["BaseHosCount"] = "1";
        //                }
        //                break;
        //            case 1:
        //                if (ViewState["ScreenCount"] == null)
        //                {
        //                    DRScreenCampView();                       
        //                    ViewState["ScreenCount"] = "1";
        //                }        
        //                break;
        //            case 2:
        //                if (ViewState["AwareCount"] == null)
        //                {
        //                    DRAwarenessView();
        //                    ViewState["AwareCount"] = "1";
        //                }      
                        
        //                break;
        //        } 
        //    }     
            
        //}

    protected void ajaxtabDRCamp_ActiveTabChanged(object sender, EventArgs e)

     {

           switch (ajaxtabDRCamp.ActiveTabIndex)

            {

                 case 0:

                      if (ViewState["BaseHosCount"] == null)

                      {

                       Bind Data();

                         ViewState["BaseHosCount"] = "1";

                     }

                       break;

                 case 1:

                   if (ViewState["ScreenCount"] == null)

                 {

                      Bind Data2();

                        ViewState["ScreenCount"] = "1";

                    }            

                 break;

            case 2:

              if (ViewState["AwareCount"] == null)

                    {

                       DRAwarenessEdit();    

                 }   

                  break;

                           }

  • Re: How to refresh on tab change?

    10-27-2009, 10:24 AM
    • Contributor
      3,377 point Contributor
    • mychucky
    • Member since 03-20-2006, 5:01 PM
    • Posts 2,530

    Rakeshkr, thank you so much for the sample code. I'll definitely give that a try.

  • Re: How to refresh on tab change?

    10-27-2009, 10:34 AM
    • Star
      8,789 point Star
    • Pawan_Mishra
    • Member since 03-13-2008, 11:37 AM
    • Bangalore
    • Posts 1,281

    Hi

    You can use what is mentioned by "Vince" , the property OnActiveTabChanged event and attach an event handler in your client side code.In that you can either use asp.net ajax web service to perform DB operation or use javascript __doPostback() method to fire a complete page postback.

    Also you can chk out my blog explaining on how you can get more hold on AjaxControlToolkit by inspecting the internals of its extender control source code.Following is the URL :-

    http://weblogs.asp.net/pawanmishra/archive/2009/10/18/working-with-ajaxcontroltoolkit.aspx

    Regards
    Pawan Mishra

    Moving from Asp.Net to WPF and SilverLight .....

    .Net 360°
  • Re: How to refresh on tab change?

    10-27-2009, 10:37 AM
    • Contributor
      3,377 point Contributor
    • mychucky
    • Member since 03-20-2006, 5:01 PM
    • Posts 2,530

    Quick question. Why do I need a swtich...case if all I want is re-bind the data again? Can you explain the idea behind the swithc...case?

  • Re: How to refresh on tab change?

    10-27-2009, 10:49 AM
    • Contributor
      3,377 point Contributor
    • mychucky
    • Member since 03-20-2006, 5:01 PM
    • Posts 2,530

    Okay, here's a dumb question.

    Why can't I type in Databind() inside of the ActiveTabChanged method? I tried it and it's not working.

  • Re: How to refresh on tab change?

    10-27-2009, 10:42 PM

     Did you use any updatepanel there? If you trigger ActiveTabChanged event, it will do full postback and execute databind. If you used updatepanel, you had better use it to wrap the entire tabcontainer.


    Vince Xu
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: How to refresh on tab change?

    10-29-2009, 11:13 AM
    • Contributor
      3,377 point Contributor
    • mychucky
    • Member since 03-20-2006, 5:01 PM
    • Posts 2,530

    Vince Xu - MSFT:

     Did you use any updatepanel there? If you trigger ActiveTabChanged event, it will do full postback and execute databind. If you used updatepanel, you had better use it to wrap the entire tabcontainer.

    That's a good idea but as I said in my previous post, DataBind() inside of the ActiveTabChanged method does not work.

  • Re: How to refresh on tab change?

    10-29-2009, 10:31 PM

    Was it able to do postback? Could you please post your code behind and html code?


    Vince Xu
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: How to refresh on tab change?

    11-07-2009, 2:26 AM
    • Member
      402 point Member
    • Rakeshkr
    • Member since 10-09-2009, 10:55 AM
    • Bangalore
    • Posts 82

    Hi,

    its depends upon your no. of tab using in your application

    if no. of tab is more than better to use switch 

    it make your application faster than if else laddder statement.


Page 1 of 2 (17 items) 1 2 Next >