Problem re-selecting a tab programmatically on button click

3 posts, 0 answers
  1. blablabla
    blablabla avatar
    23 posts
    Member since:
    Jul 2011

    Posted 22 Jul 2011 Link to this post

    Hi,

    Here's the situation:

    I have a search box in a master page. I expose the click event of the search button to my actual page that contains a radtabstrip control. The event then takes the keyword, and creates a new table for that keyword with the value "keyword" (let's call it SearchTab). This also means that I'm also creating a corresponding PageView that sends the keyword as a querystring to the page that's set in the "ContentURL" property, let's call it "SearchPage".

    This web form contains a simple label, for which the value is retrieved from the querystring.

    If the user puts a keyword and the tabstrip control does not contain a tab with the the value keyword, then I will create a new tab, otherwise, I will go and select the already existing tab.

    On to the problem:

    When I do a search for a new keyword, all works fine and dandy.
    When I do a search for an already existing keyword, and I go to select the existing tab, nothing is displayed in the tab anymore. This keeps happening if i change tabs again and then go back to that same tab. I also tried w/ and w/o AutoPostback.

    Here's the simple sample code that I'm using:

    edit: I actually removed the code that sets the contentURL and replaced it by a simple calendar just to check if it might be related to that, and that's what I ended up copying. Sorry about the error, but it doesn't make a difference (just in case you're wondering).

    if (RadTabStrip1.FindTabByValue(keyword) == null)
    {
        // Create new tab and corresponding pageview and then select it.
       RadTab SearchTab = new RadTab(String.Format("Search: {0}", keyword), keyword);
       RadPageView SearchPage = new RadPageView();
     
       SearchPage.ID = keyword;
       SearchPage.Controls.Add(new Calendar());
       SearchTab.PageViewID = SearchPage.ID;
     
       RadMultiPage1.PageViews.Add(SearchPage);
       RadTabStrip1.Tabs.Add(SearchTab);
     
       RadTabStrip1.FindTabByValue(keyword).Selected = true;
       RadMultiPage1.FindPageViewByID(keyword).Selected = true;
    }
    else
    {
        // Select the already existing tab
       RadTabStrip1.FindTabByValue(keyword).Selected = true;
       RadMultiPage.FindPageViewByID(keyword).Selected = true;
    }


    Any ideas on why this is not working?

    Thank you.
  2. blablabla
    blablabla avatar
    23 posts
    Member since:
    Jul 2011

    Posted 25 Jul 2011 Link to this post

    Answering my own post.

    I beleive the reason for this is that I was adding tabs, pages, and controls dynamically. In that case, changing tabs means losing the information inside the tab, and so i need to re-add it again.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 27 Jul 2011 Link to this post

    Hi Blablabla,

    I'm glad that you have managed to find the reason and the solution to your problem.

    You are right that when you create and add controls dynamically they should be recreated  and added on every post-back.

    Greetings,
    Dimitar Terziev
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top